Can’t create user with curl

Infos:

Fresh installed up to date Debian 9 with zammad (3.1.x) installation via DEB
Windows 7 32 Bit - commandline - curl-7.66.0-win32-mingw
command:

curl -u test@zammad.com:test123 -H "Content-Type: application/json" -X POST -d '{"firstname":"Bob","lastname":"Smith","email":"email_of_customer@example.com","roles":["Customer"],"password":"some_password"}' https://xxx.zammad.com/api/v1/users

Has anyone an idea how to fix this issue
Thanks

Expected behavior:

Create a new user at zammad

Actual behavior:

I got no message after sending this command, nothing happens
the zammad log shows an fatal error:

F, [2019-11-07T15:26:21.034363 #4305-70238689860560] FATAL -- :
F, [2019-11-07T15:26:21.034472 #4305-70238689860560] FATAL -- : ActionDispatch::Http::Parameters::ParseError (785: unexpected token at ''{login:bobsmithlogin2,firstname:Bob2,lastname:Smith2,email:email_of_b$
F, [2019-11-07T15:26:21.034523 #4305-70238689860560] FATAL -- :
F, [2019-11-07T15:26:21.034600 #4305-70238689860560] FATAL -- : vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/parameters.rb:117:in `rescue in parse_formatted_parameters'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/parameters.rb:111:in `parse_formatted_parameters'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:381:in `block in POST'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/request.rb:59:in `fetch'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/request.rb:59:in `fetch_header'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:380:in `POST'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/parameters.rb:55:in `parameters'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/filter_parameters.rb:43:in `filtered_parameters'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb:23:in `process_action'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.3/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/abstract_controller/base.rb:134:in `process'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionview-5.2.3/lib/action_view/rendering.rb:32:in `process'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_controller/metal.rb:191:in `dispatch'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_controller/metal.rb:252:in `dispatch'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:34:in `serve'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb:52:in `block in serve'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb:35:in `each'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb:35:in `serve'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:840:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/omniauth-1.9.0/lib/omniauth/builder.rb:64:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/tempfile_reaper.rb:15:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/etag.rb:25:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/conditional_get.rb:38:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/head.rb:12:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:232:in `context'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:226:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/cookies.rb:670:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:98:in `run_callbacks'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in `call_app'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `block in call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `block in tagged'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:28:in `tagged'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `tagged'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:27:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/runtime.rb:22:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb:127:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/configuration.rb:227:in `call'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/server.rb:660:in `handle_request'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/server.rb:474:in `process_client'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
[829c79ed-ed79-4528-a612-cd4e0603fb49] vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

Steps to reproduce the behavior:

curl -u test@zammad.com:test123     -H "Content-Type: application/json" -X POST -d '{"firstname":"Bob","lastname":"Smith","email":"email_of_customer@example.com","roles":["Customer"],"password":"some_password"}' https://xxx.zammad.com/api/v1/users

Please provide the original code snippet that you’re using, because the error message indicates you’ve done something different than your code snippet you provided does.

closely watched, I have tested so much code snippets, here are a few of my attempts:

curl -u test@zammad.com:test123 -H "Content-Type: application/json" -X POST -d "{"login":"bobsmithlogin2","firstname":"Bob2","lastname":"Smith2","email":"email_of_bob@example.com","roles":["Customer"],"password":"some_password"}" https://xxx.zammad.com/api/v1/users
curl -u test@zammad.com:test123 -H "Content-Type: application/json" -X POST -d "{"login":"bobsmithlogin2","firstname":"Bob2","lastname":"Smith2","email":"email_of_bob@example.com","roles":"Customer","password":"some_password"}" https://xxx.zammad.com/api/v1/users
curl -u test@zammad.com:test123 -H "Content-Type:application/json" -X POST -d "{"login":"bobsmithlogin2","firstname":"Bob2","lastname":"Smith2","email":"email_of_bob@example.com","roles":"Customer","password":"some_password"}" https://xxx.zammad.com/api/v1/users
curl -u test@zammad.com:test123 -H "Content-Type:application/json" -X POST -d '{"login":"bobsmithlogin2","firstname":"Bob2","lastname":"Smith2","email":"email_of_bob@example.com","roles":"Customer","password":"some_password"}' https://xxx.zammad.com/api/v1/users

After hours of testing, i found an solution for me:

curl -u test@zammad.com:test123 -X POST -d "login=bobsmithlogin4" -d "firstname=Bob4" -d "lastname=Smith4" -d "email=email_of_bob4@example.com" -d "roles=Customer" -d "password=some_password" https://xxx.zammad.com/api/v1/users

Glad you could solve your issue. Just for completness, this would work as well:

curl -X POST \
  https://domain.tld/api/v1/users \
  -H 'Authorization: Bearer mysecret' \
  -H 'Content-Type: application/json' \
  -d '{"login":"bobsmithlogin2","firstname":"Bob2","lastname":"Smith2","email":"email_of_bob@example.com","roles":"Customer","password":"some_password"}'

Just a small service hint: You should think about using API-Tokens instead of username & password combination, not just for better control, but also performance reasons.

At any time using the API, you should -always- prefer API-Tokens. Above exmaple uses Tokens - you can remove the authorization header and add basic auth headers if needed.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.