REST API's not returning response ?

Gaurav Kumar15
Giga Guru

Hi Team,

I am using the OOB rest API for incident table :-

https://instance.service-now.com/api/now/table/incident

I have few doubts :-

1. For creating incident via REST API , if we have to pass the username of Caller

'caller_id':'cb3230342bb3d60083dac7ac17da15af'

e.g :- This i am using for populating a user, is there any other way of populating caller, because 3rd party tool might not aware of the sys id of user record. So how rest will create the incident for some other user.

2. When i am hitting this Rest API, then the incident is getting created but Response is showing as empty in other tool. Does anyone knows why it comes as empty.

Thanks & Regards,

Gaurav Kumar

35 REPLIES 35

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Gaurav,



You may find below link helpful.


TechNow Episode 18 | REST API - YouTube


Chuck Tomasi
Tera Patron

Hi Gaurav,



I recommend against creating incidents using the table API. Instead, consider using the import API.



Consider using the REST API Explorer to help craft the REST request and expected response.



ServiceNow Developers - Import Set API


ServiceNow Developers   - REST API Explorer


Thaks a lot Pradeep and Chuck for your response.



So according to you, it is recommended that we should create a import set API in that we can transform the fields in a way we want.
I was aware of that, i thought maybe if Service Now have provided OOB table API's, so i should use that first.



Thanks chuck, i will create the customize rest api for this.



In import set api's, also i have one question.



Scenario :- Sometimes we use the import set api, so whenever the 3rd party post that data. We do all the processing in transform script and do the needful. In this case as we haven't mapped any field of target table. The 3rd party received the response as :-



"status":"error","error_message":"Target record not found"



Is there any way, we can customize status and error_message in the transform script ?




Thanks,


Gaurav Kumar


Hi Gaurav,



To customize the output message would require you to create a scripted REST API. Check episode 23 here: TechNow Episode List or this scripted REST API page on ServiceNow Developers