ewsterrenburg / python-otrs

Pythonic interface to OTRS SOAP API
GNU General Public License v3.0
47 stars 27 forks source link

Issue adding article to existing ticket #12

Closed mjducharme closed 8 years ago

mjducharme commented 8 years ago

Hi,

I have successfully created tickets, searched tickets, and updated ticket details with this, but an attempt to add an article to a ticket results in an Internal Server Error in OTRS 5, the current release. I believe it is due to the organization of the XML submitted to OTRS - the ticket number and session ID should be in the XML before the Article, and instead the article is before those two.

ewsterrenburg commented 8 years ago

@mjducharme Not entirely impossible, yet I believe something else will be going wrong here. What is the output of the debugger of the webservice for the corresponding request? (Admin --> Webservices --> GenericTicketConnectorSOAP --> Debugger)

mjducharme commented 8 years ago

I will check on Monday when I have access to the server again, but I was checking the debugger all through the process. If I recall correctly, it is logging everything to the debugger except for that one request that results in the internal server error. I figured the Internal Server Error was preventing the debugger from completing the process, through some kind of exception that they haven't programmed into their logging. Either way, the Internal Server Error HTML page is being fed back to your script instead of an XML response which is causing the script to error out in parsing the XML (because it's not XML). I cannot get you more details until Monday unfortunately.

mjducharme commented 8 years ago

OK I just checked, I was wrong, the debugger is logging it; however, the debugger is not logging the final two sections, "Outgoing data before mapping" and "Returning provider data to remote system". The debugger output is pasted here:

Request Details Communication sequence started (2016-04-29 16:21:00, debug)

$VAR1 = { 'CONTENT_LENGTH' => '630', 'CONTENT_TYPE' => 'text/xml;charset=utf-8', 'CONTEXT_DOCUMENT_ROOT' => '/opt/otrs/bin/cgi-bin/', 'CONTEXT_PREFIX' => '/otrs/', 'DOCUMENT_ROOT' => '/var/www/html', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'HTTP_ACCEPT_ENCODING' => 'identity', 'HTTP_CONNECTION' => 'close', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Python-urllib/2.7', 'MOD_PERL' => 'mod_perl/2.0.9dev', 'MOD_PERL_API_VERSION' => '2', 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin', 'PATH_INFO' => '/Webservice/GenericTicketConnector', 'PATH_TRANSLATED' => '/var/www/html/Webservice/GenericTicketConnector', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_PORT' => '33386', 'REQUEST_METHOD' => 'POST', 'REQUEST_SCHEME' => 'http', 'REQUEST_URI' => '/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector', 'SCRIPT_FILENAME' => '/opt/otrs/bin/cgi-bin/nph-genericinterface.pl', 'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_ADMIN' => 'root@localhost', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SIGNATURE' => '', 'SERVER_SOFTWARE' => 'Apache/2.4.6 (CentOS) PHP/5.4.16 mod_perl/2.0.9dev Perl/v5.16.3', 'UNIQUE_ID' => 'VyPQPG7GLsfdjp33ioVobAAAAAg' };

Received data by provider from remote system (2016-04-29 16:21:00, debug)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.otrs.org/TicketConnector/"> soapenv:Header/ soapenv:Body

text/plain0Event: SUMMARY Cleared by: CLEARID At: STATECHANGE Device: DEVICE Component: COMPONENT Severity: SEVERITY Message:

MESSAGE

Reopen: REOPENURLUTF8[zenoss] CLEAR: DEVICE CLEARSUMMARY

cfSW5N56PWtTtJyEvSz3P9CHAgobE8dd621384/soapenv:Body /soapenv:Envelope

Detected operation 'TicketUpdate' (2016-04-29 16:21:00, debug)

No data provided

Incoming data before mapping (2016-04-29 16:21:00, debug)

$VAR1 = { 'Article' => { 'Body' => 'Event: SUMMARY Cleared by: CLEARID At: STATECHANGE Device: DEVICE Component: COMPONENT Severity: SEVERITY Message:

MESSAGE

Reopen: REOPENURL', 'Charset' => 'UTF8', 'MimeType' => 'text/plain', 'Subject' => '[zenoss] CLEAR: DEVICE CLEARSUMMARY', 'TimeUnit' => '0' }, 'SessionID' => 'cfSW5N56PWtTtJyEvSz3P9CHAgobE8dd', 'TicketID' => '621384' };

ewsterrenburg commented 8 years ago

Hmm, not too helpful for me at least. Can you intercept the request (with feedly or something similar) and post both the intercepted request and the working equivalent when you post it directly (i.e. without the use of python-otrs)?

On Mon, May 2, 2016 at 3:56 PM, Michael Ducharme notifications@github.com wrote:

OK I just checked, I was wrong, the debugger is logging it; however, the debugger is not logging the final two sections, "Outgoing data before mapping" and "Returning provider data to remote system". The debugger output is pasted here:

Request Details Communication sequence started (2016-04-29 16:21:00, debug)

$VAR1 = { 'CONTENT_LENGTH' => '630', 'CONTENT_TYPE' => 'text/xml;charset=utf-8', 'CONTEXT_DOCUMENT_ROOT' => '/opt/otrs/bin/cgi-bin/', 'CONTEXT_PREFIX' => '/otrs/', 'DOCUMENT_ROOT' => '/var/www/html', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'HTTP_ACCEPT_ENCODING' => 'identity', 'HTTP_CONNECTION' => 'close', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Python-urllib/2.7', 'MOD_PERL' => 'mod_perl/2.0.9dev', 'MOD_PERL_API_VERSION' => '2', 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin', 'PATH_INFO' => '/Webservice/GenericTicketConnector', 'PATH_TRANSLATED' => '/var/www/html/Webservice/GenericTicketConnector', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_PORT' => '33386', 'REQUEST_METHOD' => 'POST', 'REQUEST_SCHEME' => 'http', 'REQUEST_URI' => '/otrs/ nph-genericinterface.pl/Webservice/GenericTicketConnector', 'SCRIPT_FILENAME' => '/opt/otrs/bin/cgi-bin/nph-genericinterface.pl', 'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_ADMIN' => 'root@localhost', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SIGNATURE' => '', 'SERVER_SOFTWARE' => 'Apache/2.4.6 (CentOS) PHP/5.4.16 mod_perl/2.0.9dev Perl/v5.16.3', 'UNIQUE_ID' => 'VyPQPG7GLsfdjp33ioVobAAAAAg' };

Received data by provider from remote system (2016-04-29 16:21:00, debug)

xmlns="http://www.otrs.org/TicketConnector/"> soapenv:Header/ soapenv:Body text/plain0Event: SUMMARY Cleared by: CLEARID At: STATECHANGE Device: DEVICE Component: COMPONENT Severity: SEVERITY Message:

MESSAGE

Reopen: REOPENURLUTF8[zenoss] CLEAR: DEVICE CLEARSUMMARY cfSW5N56PWtTtJyEvSz3P9CHAgobE8dd621384/soapenv:Body /soapenv:Envelope

Detected operation 'TicketUpdate' (2016-04-29 16:21:00, debug)

No data provided

Incoming data before mapping (2016-04-29 16:21:00, debug)

$VAR1 = { 'Article' => { 'Body' => 'Event: SUMMARY Cleared by: CLEARID At: STATECHANGE Device: DEVICE Component: COMPONENT Severity: SEVERITY Message:

MESSAGE

Reopen: REOPENURL', 'Charset' => 'UTF8', 'MimeType' => 'text/plain', 'Subject' => '[zenoss] CLEAR: DEVICE CLEARSUMMARY', 'TimeUnit' => '0' }, 'SessionID' => 'cfSW5N56PWtTtJyEvSz3P9CHAgobE8dd', 'TicketID' => '621384' };

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/ewsterrenburg/python-otrs/issues/12#issuecomment-216242593

mjducharme commented 8 years ago

Found and fixed the problem, it is a bug in OTRS, not your code. There was a typo in a perl file that only affects TicketUpdate (not TicketCreate) where TimeUnit is being specified:

/opt/otrs/Kernel/GenericInterface/Operation/Ticket/TicketUpdate.pm

Line 14 should say:

use Kernel::System::VariableCheck qw(IsArrayRefWithData IsHashRefWithData IsStringWithData);

In the relased version it instead says:

use Kernel::System::VariableCheck qw(IsArrayRefWithData IsHashRefWithData IsString);

IsStringWithData is used to process incoming TimeUnit data and so the typo causes the internal server error when TimeUnit is used.

ewsterrenburg commented 8 years ago

@mjducharme Thanks for the thorough investigation. Will you report this issue? And can I close this issue here?

mjducharme commented 8 years ago

I reported it last night and they fixed it a few hours after I reported it. Their fix is here:

https://github.com/OTRS/otrs/commit/f7c3826b1329ccca42be196f76d0e0dc503a9338

ewsterrenburg commented 8 years ago

Ok, good to know :)