The CreatorCon Call for Content is officially open! Get started here.

How to check nested json object value in sysparm_query?

glebr
Kilo Contributor

Hello
I need to get list of change_tasks for given change_request sys_id through REST API.
I make GET response for 'change_task' table, and receive response

{

  "result": [

                  {

                            "sys_id": "---task-sys-id---",

                            "change_request": {

                                      "link": "https://[instance].service-now.com/api/now/table/change_request/---request-sys-id---",

                                      "value": "---request-sys-id---"

                                      },

                  }
]

}

How can I add filter to GET request using sysparm_query to check for change_request.value field?


I am looking to something like "sysparm_query=change_request.value=---request-sys-id---".
I have no problem checking for simple fields, but cannot find documentation for syntax for nested json object.

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Gleb,



That value property only exists in the JSON response. If you want to query on the sys_id of the change request from the change task, your query should be:



sysparm_query=change_request=---change request sysid---



So altogether that would be:



https://[instanceName].service-now.com/api/now/table/change_task?sysparm_query=change_request=---cha... request sysid---


View solution in original post

5 REPLIES 5

Hi Brad,



I have a similar problem where I am trying to query the incidents related to a specific CI.   My first attempt was to use a nested json query to locate the value property of the cmdb_ci in the query of the incidents table.     But similar to @glebr's post it's not working.   Is there another approach?



{


      "result": [


              {


                      "number": "INC0000001",


                      "closed_at": "2017-08-12 23:10:06",


                      "cmdb_ci": {


                              "link": "https://[instance].service-now.com/api/now/v1/table/cmdb_ci/b0c4030ac0a800090152e7a4564ca36c",


                              "value": "b0c4030ac0a800090152e7a4564ca36c"


                      },


                      ...


              }


        ]


}