Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OTRS Generic Interface (Search ticket) - Array for URL Query Param

Tags:

curl

otrs

Scroll down @ OTRS Admin Documentation : Here you find the curl statement for search ticket operations.

curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=agent&Password=123&Queue=Postmaster"

Does someone knows how to search for 2 different queues in one curl statement? Yes I can do 2 curl requests, but if it is possible one single request would be better.

I tried some URL query param array stuff, but nothing works, e.g.

//just second Queue is used!!!
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=agent&Password=123&Queue=Postmaster&Queue=Postmaster2"

//
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=agent&Password=123&Queue[]=Postmaster&Queue[]=Postmaster2"

//
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=agent&Password=123&Queue=Postmaster,Postmaster2"

    //
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=agent&Password=123&Queue=[Postmaster,Postmaster2]"
like image 646
heaphach Avatar asked Jun 03 '15 11:06

heaphach


1 Answers

I'm not sure it's possible using a GET method if I look briefly at the OTRS sources. But there is a way to supply a parameter more than once if you switch the TicketSearch operation to POST and supply the query parameters via JSON.

Configuring the web service is relatively easy; in OTRS you should navigate to Admin > Web Services. Select the 'Rest" web service. Choose the 'Configure' button next to the network transport ('HTTP::REST').

Now update the route mapping for TicketSearch from Ticket to something unique, for example TicketSearch. Otherwise, POST requests to the Ticket route will end up in the TicketCreate operation. See the screenshot below:

enter image description here

Now you can pass the parameters as a JSON document. The curl example looks like this:

curl -X POST --data '{"Queues": ["Bar", "Foo"]}' \
"http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/TicketSearch?UserLogin=test&Password=test"

Please note that if one of your queue names does not exist, the search will return no tickets.

like image 65
MichielB Avatar answered Nov 12 '22 07:11

MichielB