Article creation does not work with REST?

Hi, using Zammad 2.2.0 API

my aim is to generate an Article for a Ticket. Using the Ruby API, that works fine. I load the Ticket, create ticket from that, fill in data, and there is my Article attached to the Ticket.

ticket = client.ticket.find(6)

article = ticket.article(
  type: 'note',
  subject: 'some subject 2',
  body: 'Yuhuu',
  content_type: 'text/html', # optional, default is text/plain
  internal: true
)

Now trying this with the RESTful API in Python I dont get it to work. Here is a python test snippet:

endpoint = '/ticket_articles/by_ticket/6'
response = requests.get(urlbase + endpoint, headers=head)
print (response)

endpoint = '/ticket_articles'
article = {
    'ticket_id':6,
    "type": "note",
    "internal": "true",
    "content_type": "text/html",
    "subject": "Test",
    "body": "Test"
}
json_article = json.dumps(article)
print (json_article)

response = requests.post(urlbase + endpoint, data=json_article, headers=head)
print (response.text)

When I load Ticket 6 that shows up. But when I try to create the new article for it, it complains with
"ERROR: Could not find Ticket with Id=".
Obviously it does not recognize the given ticket id.

Transforming this to a CURL requests, executes, but does not generate any article at all.

/curl 
-u user:pass 
-H "Content-Type: application/json" 
-X post 
-d '{"ticket_id": 6, "type": "note", "internal": "true", "content_type": "text/html", "subject": "Test", "body": "Test"}' 
http://localhost:3000/api/v1/ticket_articles

Is this a bug or am I doing something wrong?
Cheers,
Oliver

Please provide your logfile.

here is a log, thx for looking into it

I, [2018-01-11T22:37:02.128791 #3379] INFO – : Scheduler started.
I, [2018-01-11T22:37:02.226270 #3379] INFO – : Scheduler running…
I, [2018-01-11T22:37:02.243517 #3379] INFO – : Started job thread for ‘Check streams for Channel’ (Channel.stream)…
I, [2018-01-11T22:37:02.294311 #3379] INFO – : execute Channel.stream (try_count 0)…
I, [2018-01-11T22:37:08.325199 #3377] INFO – : Started GET “/api/v1/ticket_articles/by_ticket/6” for 127.0.0.1 at 2018-01-11 22:37:08 +0100
I, [2018-01-11T22:37:08.328397 #3377] INFO – : Started GET “/api/v1/cti/log?=1515517822792" for 127.0.0.1 at 2018-01-11 22:37:08 +0100
I, [2018-01-11T22:37:08.428738 #3377] INFO – : Started GET "/api/v1/tickets/6?all=true&
=1515517822793” for 127.0.0.1 at 2018-01-11 22:37:08 +0100
I, [2018-01-11T22:37:08.440998 #3377] INFO – : Processing by TicketArticlesController#index_by_ticket as /
I, [2018-01-11T22:37:08.445346 #3377] INFO – : Parameters: {“id”=>“6”}
I, [2018-01-11T22:37:08.447930 #3377] INFO – : Started GET “/api/v1/tickets/18?all=true&=1515517822794" for 127.0.0.1 at 2018-01-11 22:37:08 +0100
I, [2018-01-11T22:37:08.626226 #3377] INFO – : Processing by CtiController#index as JSON
I, [2018-01-11T22:37:08.626395 #3377] INFO – : Parameters: {"
”=>“1515517822792”}
I, [2018-01-11T22:37:08.684930 #3377] INFO – : Processing by TicketsController#show as JSON
I, [2018-01-11T22:37:08.685103 #3377] INFO – : Parameters: {“all”=>“true”, “"=>“1515517822793”, “id”=>“6”}
I, [2018-01-11T22:37:08.686988 #3377] INFO – : Completed 200 OK in 60ms (Views: 0.6ms | ActiveRecord: 32.5ms)
I, [2018-01-11T22:37:08.886352 #3377] INFO – : Processing by TicketsController#show as JSON
I, [2018-01-11T22:37:08.886566 #3377] INFO – : Parameters: {“all”=>“true”, "
”=>“1515517822794”, “id”=>“18”}
I, [2018-01-11T22:37:09.307552 #3377] INFO – : Completed 200 OK in 421ms (Views: 5.7ms | ActiveRecord: 288.4ms)
I, [2018-01-11T22:37:09.697389 #3377] INFO – : Completed 200 OK in 1012ms (Views: 81.5ms | ActiveRecord: 629.1ms)
I, [2018-01-11T22:37:10.218432 #3377] INFO – : Completed 200 OK in 1773ms (Views: 62.3ms | ActiveRecord: 753.3ms)
I, [2018-01-11T22:37:10.226681 #3379] INFO – : Starting worker thread Delayed::Backend::ActiveRecord::Job
I, [2018-01-11T22:37:10.243864 #3377] INFO – : Started POST “/api/v1/ticket_articles” for 127.0.0.1 at 2018-01-11 22:37:10 +0100
I, [2018-01-11T22:37:10.257855 #3377] INFO – : Processing by TicketArticlesController#create as /
I, [2018-01-11T22:37:10.258004 #3377] INFO – : Parameters: {"{“ticket_id”: 6, “type”: “note”, “internal”: “true”, “content_type”: “text/html”, “subject”: “Test”, “body”: “Test”}"=>nil}
I, [2018-01-11T22:37:10.272535 #3379] INFO – : 2018-01-11T22:37:10+0100: [Worker(host:localhost.localdomain pid:3379)] Job Observer::UserDeviceLogJob (id=4626) RUNNING
I, [2018-01-11T22:37:10.302731 #3379] INFO – : 2018-01-11T22:37:10+0100: [Worker(host:localhost.localdomain pid:3379)] Job Observer::UserDeviceLogJob (id=4626) COMPLETED after 0.0299
E, [2018-01-11T22:37:10.408378 #3377] ERROR – : Couldn’t find Ticket with ‘id’= (ActiveRecord::RecordNotFound)
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/composite_primary_keys-10.0.1/lib/composite_primary_keys/core.rb:48:in find' /opt/zammad/app/controllers/ticket_articles_controller.rb:86:increate’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/basic_implicit_render.rb:4:in send_action' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:186:inprocess_action’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/rendering.rb:30:in process_action' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:20:inblock in process_action’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:131:in run_callbacks' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:19:inprocess_action’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/rescue.rb:20:in process_action' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:32:inblock in process_action’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in block in instrument' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:ininstrument’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in instrument' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:30:inprocess_action’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/params_wrapper.rb:252:in process_action' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/controller_runtime.rb:22:inprocess_action’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:124:in process' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/rendering.rb:30:inprocess’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:189:in dispatch' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:253:indispatch’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:49:in dispatch' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:31:inserve’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:50:in block in serve' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:ineach’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in serve' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:834:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:190:in call!' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/strategy.rb:168:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/omniauth-1.7.1/lib/omniauth/builder.rb:63:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/etag.rb:25:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/conditional_get.rb:38:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/head.rb:12:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/session/abstract/id.rb:232:in context' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/session/abstract/id.rb:226:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/cookies.rb:613:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/callbacks.rb:26:inblock in call’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:97:in run_callbacks' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/callbacks.rb:24:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/debug_exceptions.rb:59:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/show_exceptions.rb:31:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:36:in call_app' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:24:inblock in call’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/tagged_logging.rb:69:in block in tagged' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/tagged_logging.rb:26:intagged’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/tagged_logging.rb:69:in tagged' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:24:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/remote_ip.rb:79:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/request_id.rb:25:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/method_override.rb:22:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/runtime.rb:22:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/executor.rb:12:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/static.rb:125:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/sendfile.rb:111:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/engine.rb:522:in call' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/configuration.rb:225:incall’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/server.rb:624:in handle_request' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/server.rb:438:inprocess_client’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/server.rb:302:in block in run' /opt/zammad/vendor/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/thread_pool.rb:120:inblock in spawn_thread’
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context’
I, [2018-01-11T22:37:10.409551 #3377] INFO – : Completed 404 Not Found in 151ms (Views: 0.3ms | ActiveRecord: 84.3ms)
I, [2018-01-11T22:37:11.419755 #3377] INFO – : Started GET “/api/v1/online_notifications/?full=true&=1515517822795" for 127.0.0.1 at 2018-01-11 22:37:11 +0100
I, [2018-01-11T22:37:11.431299 #3377] INFO – : Processing by OnlineNotificationsController#index as JSON
I, [2018-01-11T22:37:11.431439 #3377] INFO – : Parameters: {“full”=>“true”, "
”=>“1515517822795”}
I, [2018-01-11T22:37:11.530443 #3377] INFO – : Completed 200 OK in 99ms (Views: 12.2ms | ActiveRecord: 13.3ms)
I, [2018-01-11T22:37:12.245839 #3379] INFO – : Started job thread for ‘Import OTRS diff load’ (Import::OTRS.diff_worker)…
I, [2018-01-11T22:37:12.294590 #3379] INFO – : execute Import::OTRS.diff_worker (try_count 0)…
I, [2018-01-11T22:37:16.692431 #3377] INFO – : Started GET “/api/v1/channels_email?=1515517822796" for 127.0.0.1 at 2018-01-11 22:37:16 +0100
I, [2018-01-11T22:37:16.703919 #3377] INFO – : Processing by ChannelsEmailController#index as JSON
I, [2018-01-11T22:37:16.704064 #3377] INFO – : Parameters: {"
”=>“1515517822796”}
I, [2018-01-11T22:37:16.750590 #3377] INFO – : Completed 200 OK in 46ms (Views: 4.2ms | ActiveRecord: 8.2ms)
I, [2018-01-11T22:37:18.332127 #3379] INFO – : 2018-01-11T22:37:18+0100: [Worker(host:localhost.localdomain pid:3379)] Job Observer::UserDeviceLogJob (id=4627) RUNNING
I, [2018-01-11T22:37:18.360302 #3379] INFO – : 2018-01-11T22:37:18+0100: [Worker(host:localhost.localdomain pid:3379)] Job Observer::UserDeviceLogJob (id=4627) COMPLETED after 0.0279
I, [2018-01-11T22:37:22.246769 #3379] INFO – : Started job thread for ‘Check Channels’ (Channel.fetch)…
I, [2018-01-11T22:37:22.294162 #3379] INFO – : execute Channel.fetch (try_count 0)…
I, [2018-01-11T22:37:22.298877 #3379] INFO – : fetching imap (imap.variomedia.de/support@sieben.co.uk port=143,ssl=false,folder=INBOX,keep_on_server=false)
I, [2018-01-11T22:37:22.986022 #3379] INFO – : - no message
I, [2018-01-11T22:37:22.986196 #3379] INFO – : done
I, [2018-01-11T22:37:32.247645 #3379] INFO – : Started job thread for ‘Process pending tickets’ (Ticket.process_pending)…
I, [2018-01-11T22:37:32.294322 #3379] INFO – : execute Ticket.process_pending (try_count 0)…
I, [2018-01-11T22:37:32.329906 #3379] INFO – : …stopped thread for 'Ticket.process_pending’
I, [2018-01-11T22:37:42.248316 #3379] INFO – : Started job thread for ‘Process escalation tickets’ (Ticket.process_escalation)…
I, [2018-01-11T22:37:42.278014 #3379] INFO – : execute Ticket.process_escalation (try_count 0)…
I, [2018-01-11T22:37:46.696493 #3377] INFO – : Started GET “/api/v1/channels_email?=1515517822797" for 127.0.0.1 at 2018-01-11 22:37:46 +0100
I, [2018-01-11T22:37:46.713906 #3377] INFO – : Processing by ChannelsEmailController#index as JSON
I, [2018-01-11T22:37:46.714083 #3377] INFO – : Parameters: {"
”=>“1515517822797”}
I, [2018-01-11T22:37:46.757794 #3377] INFO – : Completed 200 OK in 44ms (Views: 4.4ms | ActiveRecord: 7.7ms)
I, [2018-01-11T22:37:52.249042 #3379] INFO – : Started job thread for ‘Generate Session data’ (Sessions.jobs)…
I, [2018-01-11T22:37:52.298529 #3379] INFO – : execute Sessions.jobs (try_count 0)…
I, [2018-01-11T22:37:53.051576 #3379] INFO – : execute Channel.fetch (try_count 0)…
I, [2018-01-11T22:37:53.055260 #3379] INFO – : fetching imap (imap.variomedia.de/support@sieben.co.uk port=143,ssl=false,folder=INBOX,keep_on_server=false)
I, [2018-01-11T22:37:53.665427 #3379] INFO – : - no message
I, [2018-01-11T22:37:53.665600 #3379] INFO – : done
I, [2018-01-11T22:38:02.250747 #3379] INFO – : Started job thread for ‘Execute jobs’ (Job.run)…
I, [2018-01-11T22:38:02.305833 #3379] INFO – : execute Job.run (try_count 0)…
I, [2018-01-11T22:38:16.693885 #3377] INFO – : Started GET “/api/v1/channels_email?=1515517822798" for 127.0.0.1 at 2018-01-11 22:38:16 +0100
I, [2018-01-11T22:38:16.704387 #3377] INFO – : Processing by ChannelsEmailController#index as JSON
I, [2018-01-11T22:38:16.704545 #3377] INFO – : Parameters: {"
”=>“1515517822798”}
I, [2018-01-11T22:38:16.749342 #3377] INFO – : Completed 200 OK in 45ms (Views: 4.7ms | ActiveRecord: 7.4ms)
I, [2018-01-11T22:38:23.773207 #3379] INFO – : execute Channel.fetch (try_count 0)…
I, [2018-01-11T22:38:23.776378 #3379] INFO – : fetching imap (imap.variomedia.de/support@sieben.co.uk port=143,ssl=false,folder=INBOX,keep_on_server=false)
I, [2018-01-11T22:38:24.382441 #3379] INFO – : - no message
I, [2018-01-11T22:38:24.382657 #3379] INFO – : done

Closed … my fault … converted json to json, what caused the troubles.

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