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

srinivasthelu
Tera Guru

Hi Gleb,



Are you facing any issues with using direct sysparm_query for dot walking field.



https://[instanceName].service-now.com/api/now/table/change_task?sysparm_limit=10&sysparm_query=chan..."what ever the value" is not working?



Thanks


Srinivas


Hi Srinivas,
Yes the link you included didn't work for me. But Brad`s solution completely solves my issue. Thank you for help.


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---


Thank you for help, that is what i needed.