Example of using the simplified REST API to search for a ticket


The following example demonstrates how you can use the BMC Helix ITSM simplified API to search for an incident, change, or problem ticket.


cURL example

curl -X 'POST' \
  'https://<Innovation Suite server URL>/api/com.bmc.dsm.itsm.itsm-rest-api/v2/ticket/search?filter=my%20group' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "limit": 10,
  "offset": 10,    
  "sortBy": [{ "field" : "priority", "order": "desc"}],
  "fields": "['\''id'\'','\''status'\'']",
  "criteria": {
    "bindingExpression": "AND",
    "conditions": "{\r\n              \"fieldName\": \"status\",\r\n              \"operation\": \"eq\",\r\n              \"fieldValue\": \"27000\"\r\n          },\r\n          {\r\n              \"fieldName\": \"assignee\",\r\n              \"operation\": \"eq\",\r\n              \"fieldValue\": \"Allen Allbrook\"\r\n          }"
  }
}'

Request URL

https://<Innovation Suite server URL>/api/com.bmc.dsm.itsm.itsm-rest-api/v2/ticket/search?filter=my%20group


Request body

{

  "limit": 10,
  "offset": 10,     
 "sortBy": [{ "field" : "priority", "order": "desc"}],
  "fields": "['\''id'\'','\''status'\'']",
  "criteria": {
    "bindingExpression": "AND",
    "conditions": "{\r\n              \"fieldName\": \"status\",\r\n              \"operation\": \"eq\",\r\n              \"fieldValue\": \"27000\"\r\n          },\r\n          {\r\n              \"fieldName\": \"assignee\",\r\n              \"operation\": \"eq\",\r\n              \"fieldValue\": \"Allen Allbrook\"\r\n          }"
  }
}


The following example demonstrate how to perform the operation by using Postman client.

Before you begin

Make sure that you have a valid authentication token. For more information, see Access-and-authentication-for-the-simplified-REST-API.

To search for a ticket by using the simplified REST API in the Postman client

  1. Open the Postman REST Client.
  2. Set the request URL as:
    https://<Innovation Suite server URL>/api/com.bmc.dsm.itsm.itsm-rest-api/v2/ticket/search?filter=<search filter>
  3. Select the operation as POST.
  4. Click Headers.
  5. Enter the following data as key value pairs in the header:

    Key

    Value

    X-Requested-By

    XMLHttpRequest

    Content-Type

    application/json

  6. Select raw.
  7. From the list, select JSON.
  8. Enter the JSON input for searching a ticket.
    For example:

    {
        "limit": 10,
        "offset": 0,
       "sortBy": [{ "field" : "status", "order": "desc"}, { "field" : "priority", "order": "desc"}]
        "fields": ["id", "status"],
        "criteria" :
        {
            "bindingExpression": "OR",
            "conditions" :
             [
             {
                 "fieldName": "status",
                 "operation": "eq",
                 "fieldValue": "27000"
             },
             {
                 "fieldName": "assignee",
                 "operation": "eq",
                 "fieldValue": "Allen Allbrook"
             }
             ]
        }
    }

    You can customize the search criteria by using either AND or OR in bindingExpression.

  9. Click Send.
    The results are displayed on the response panel.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*