6

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]"
heaphach
  • 1,492
  • 1
  • 20
  • 44

2 Answers2

9

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.

MichielB
  • 4,181
  • 1
  • 30
  • 39
  • 1
    The example from the docs with the "Queue=*" query param didn't work at all for me (searching for a single queue). This method is the only one that worked for me. – Xceno Mar 15 '16 at 07:56
0

For posterity, and as I felt on that thread while searching for the same issue:

I made it working by using the filter "Queues", instead of "Queue", and simply repeating the parameter:

> curl -k "https://otrs02.telsys.ch/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=qmorrier***&Password=***&Queues=Nouveaux&Queues=Raw"
{"TicketID":["2","1"]}

> curl -k "https://otrs02.telsys.ch/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=qmorrier***&Password=***&Queues=Nouveaux&Queues=Raw&Queues=Niveau%201"
{"TicketID":["3","2","1"]}

I'm currently running OTRS 6.0.25 Community Edition

Quentin Morrier
  • 675
  • 5
  • 14