Create an incident related to a CI via the REST table API

Jarek1
Kilo Explorer

Hi,

I'm new to Service Now and I need to create an incident related to a CI using the REST Table API.

Actually I was able to do it by sending POST to the api/now/v2/table/incident endpoint with the below JSON attached:

{
"short_description": "testing cmdb relation",
"description": "testing cmdb relation",
"impact": "3",
"urgency": "3",
"caller_id": "jarekk",
"cmdb_ci": "affd3c8437201000deeabfc8bcbe5dc3"
}

It seems that the cmdb_ci field accepts the sys_id value of a CI. Retrieving the sys_id requires one extra step before creating an incident. I would like to avoid it.

I started to wonder if there is any other way to identify CI in the above request: by name, serial number or etc… I couldn't find comprehensive documentation. I would appreciate any guidance regarding this topic.

Thanks,
Jarek

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Jarek,

the incident table API would require cmdb_ci sys_id value since it is a reference type;

An extra call of GET to cmdb_ci with the name or serial number needs to be done & is mandatory to get the sys_id and then use it in the incident API

try giving the name as Pradeep suggested

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Jarek,

I tested via Rest API explorer and was able to create an incident by passing display value i.e name to the reference field "cmdb_ci".

Here is sample JSON:

{
"short_description": "testing cmdb relation",
"description": "testing cmdb relation",
"impact": "3",
"urgency": "3",
"caller_id": "jarekk",
"cmdb_ci": "A53 Series"
}

 

Incident Creation

find_real_file.png

 

 

Thank you for the response. It works fine.

I still wonder if there are any restriction on the cmdb_ci field. I plan to put there quite long strings which may contain non-alphanumeric characters.

Is there any documentation explaining behavior you’ve described?

Hi,

the string/name you give should be a valid record in cmdb_ci table i.e. the name should exists in the cmdb table

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader