REST API query for all incidents related to a Configuration Item

jlow
Kilo Explorer

I'm am interested in querying incidents associated with a particular CI.  The first query works, but the more detailed query does not.

Works:

https://<instance>.service-now.com/api/now/v1/table/incident?sysparm_query=cmdb_ci=b0c4030ac0a800090152e7a4564ca36c&sysparm_limit=100

Does not work:

https://<instance>.service-now.com/api/now/v1/table/incident?sysparm_query=cmdb_ci.value=b0c4030ac0a800090152e7a4564ca36c&sysparm_limit=100

Data sample:

....

    "order": "",
    "calendar_stc": "7937181",
    "closed_at": "2017-08-12 23:10:06",
    "cmdb_ci": {
        "link": "https://dev18202.service-now.com/api/now/v1/table/cmdb_ci/b0c4030ac0a800090152e7a4564ca36c",
        "value": "b0c4030ac0a800090152e7a4564ca36c"
    },
    "delivery_plan": "",
    "impact": "1",

....

 

 

2 REPLIES 2

Kunal Jha
Giga Expert

cmdb_ci is a reference field and it either require sys_id or display value to query

 

so just give sys_id value and it should query it

 "order": "",
    "calendar_stc": "7937181",
    "closed_at": "2017-08-12 23:10:06",
    "cmdb_ci": {
        "value": "b0c4030ac0a800090152e7a4564ca36c"
    },
    "delivery_plan": "",
    "impact": "1",

Harsh Vardhan
Giga Patron

Hi 

 

one quick question..

you have passed "cmdb_ci.value" may i know is this a column in your cmdb_ci table? if not then this is not correct way to do dot walking because its not a column.

 

coming to solution :-

you can simply try to pass another paramter "sysparm_display_value=true" then it will show you the display value on that cmdb_ci value.

 

Note: value always show the sys_id and if you want to see the label of that value then you need to pass "sysparm_display_value=true"

 

<your instance id>.service-now.com/api/now/table/incident?sysparm_query=cmdb_ci%3D109562a3c611227500a7b7ff98cc0dc7&sysparm_display_value=true

 

output:

 

"sys_created_by": "employee",
      "knowledge": "false",
      "order": "",
      "calendar_stc": "102,197",
      "closed_at": "2016-12-13 18:46:44",
      "cmdb_ci": {
        "display_value": "Storage Area Network 001",
        "link": "https://dev34768.service-now.com/api/now/table/cmdb_ci/109562a3c611227500a7b7ff98cc0dc7"
      },

 

Let me know if you need any further help.