Generic REST Interface TicketUpdate function with python

hi guys, im playing around with the new REST Interface struggling to find out how to pass valid data to the TicketUpdate function. I can read the TicketData with the TicketGet function without any problems, but fail to update any ticket information. I have registered the WS as following:
--- Debugger: DebugThreshold: debug TestMode: '0' Description: '' FrameworkVersion: 4.0.1 Provider: Operation: TicketGet: Description: '' MappingInbound: Type: Simple MappingOutbound: Type: Simple Type: Ticket::TicketGet TicketUpdate: Description: '' MappingInbound: Type: Simple MappingOutbound: Type: Simple Type: Ticket::TicketUpdate Transport: Config: KeepAlive: '' MaxLength: '20000000' RouteOperationMapping: TicketGet: Route: /TicketGet/:TicketID TicketUpdate: RequestMethod: - POST Route: /TicketUpdate/:TicketID Type: HTTP::REST RemoteSystem: '' Requester: Transport: Type: '
And i try to access the TicketUpdate Function via python, short snipped like this: <imports>
ticketdata = dict( UserLogin='username', Password='username', Data=dict( Ticket=dict( Title='changeme' )) ) url = 'http://myotrs/otrs/nph-genericinterface.pl/Webservice/Test/TicketUpdate/1001...' r = requests.post(url, params=ticketdata) print r.content
And the TicketUpdate function returns like:
{"TicketNumber":"2014112680000111","TicketID":"10017"}
but does not change anything in the Ticket and does not error out. Looking at the debugger it seems clear that not all data is passed in my post request:
Incoming data before mapping (2014-11-27 10:41:34, debug) $VAR1 = { 'Data' => 'Ticket', 'Password' => 'username', 'RequestMethod' => 'POST', 'TicketID' => '10017', 'UserLogin' => 'username' }; Incoming data after mapping (2014-11-27 10:41:34, debug) $VAR1 = { 'Data' => 'Ticket', 'Password' => 'username', 'RequestMethod' => 'POST', 'TicketID' => '10017', 'UserLogin' => 'username' };
but i struggle to find out how to pass it rightfully? Passing a json.dumps() generated data string will error out and urlencoding seems not the right way. Can someone give me a pointer here? Thanks! -- Michael Ablassmeier Senior Support Engineer Ziegelstrasse 1 D-83629 Weyarn Fon +49 (0) 80 20 / 180-0 Fax +49 (0) 80 20 / 180-666 Mail support@sep.de Web http://www.sep.de

Am 11/27/2014 10:50 AM, schrieb Michael Ablassmeier:
) url = 'http://myotrs/otrs/nph-genericinterface.pl/Webservice/Test/TicketUpdate/1001...'
r = requests.post(url, params=ticketdata) print r.content
cause of the issue was that i passed the data with params= and not with data=, this way it worked: ticketdata=dict( UserLogin="user", Password="pass", Ticket=dict( Title='changeme' ) ) headers = {'content-type': 'application/json'} r = requests.post(url, data=json.dumps(ticketdata), headers=headers) print(r.content) it works. -- Michael Ablassmeier Senior Support Engineer Ziegelstrasse 1 D-83629 Weyarn Fon +49 (0) 80 20 / 180-0 Fax +49 (0) 80 20 / 180-666 Mail support@sep.de Web http://www.sep.de
participants (1)
-
Michael Ablassmeier