Learn in this article how to use REST API of OTRS & Znuny to search for Tickets with specific DynamicField_NameXY content.
In the previous article Access Znuny & OTRS API via REST, we guide you thru the essential configuration steps of REST API in the role of the service provider. If you followed the steps your system is now accessible via new REST API Routes and is providing data in response to REST API requests. The default configuration of the TicketSearch route does not allow you to leverage the full power of the REST API.
Modification of the Default REST API Configuration
The default configuration of the REST API TicketSearch interface is expecting GET method at the following URL
http://{{znunyHostName}}/otrs/nph-genericinterface.pl/Webservice/{{webservice name}}
/Ticket
The GET method allows you to specify simple request options, which does not allow you to leverage from all search capabilities deployed in TicketSearch method as documented in OTRS 6.0 API Reference Perl > Perl Modules > Kernel::GenericInterface::Operation::Ticket::TicketSearch.
The fix is simple, open the webservice Network Transport configuration:
and change two options:
- Rename the TicketSearch route
- Change the expected method from GET to GET and POST
Searching for Tickets with DynamicField_NameXYZ = something
Now we can use search OTRS & Znuny using REST API leveraging from all search filters documented in OTRS 6.0 API Reference Perl > Perl Modules > Kernel::GenericInterface::Operation::Ticket::TicketSearch.
The following cURL example will search for all Tickets which have DynamicField_IsRedmineLinked value like ‘Yes*’ where asteriks is a wildcard.
curl --location --request POST 'http://localhost/otrs/nph-genericinterface.pl/Webservice/Ticket REST API/TicketSearch?SessionID=8HdMDh9iBc1fpBXqq53JCPzVLQIhIpC0&AllArticles=1&DynamicFields=1' \
--header 'Content-Type: application/json' \
--data-raw '{
"DynamicField_IsRedmineLinked":{
"Like":"Yes*"
}
}'
Related articles
Access Znuny & OTRS API via REST
Authenticate to Znuny / OTRS REST API
Examples Calling REST API of Znuny & OTRS with cURL