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

REST API - Asynchronous Inbound flow to return sys_id

CV1
Tera Contributor
Hi Everyone,
We are using REST API - Asynchronous trigger (post) and created an Inbound flow.
The requirement is after the payload from a 3rd party application is inserted to SN  table, we need to do the following :
 
Call to ServiceNow endpoint will return the sysId
{
   "sysId": "SN SysId"
}Error response
{
   "error": "description of error"
}PUT:
 
Please Note: Currently its only returning the execution id. How can this be changed to return a specific HTTP response code (200/201/400/500 etc.,)
 
Thanks in advance! 
 
 
 
11 REPLIES 11

Hi @Jugmaz,

 

With the scripted Rest API in ServiceNow, we can do whathever you've explained above, but I am asking, how we can send back the custom response with the REST API - Asynchronous Inbound flow?

 

Hope I am clear with my query!

Yes, understood.

And answer is that you need to setup the answer/response.

In a scripted web service - you need to define the Response, right!? Do that within the script of any given scripted WS, eg. between the:

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
 return response.xx // Here you return any response - do it in JSON whatsoever
})(request, response);


Please see any OOB equivalent for more info!

 

Please, trial and error helps as well as postman eg.

Hi @Jugmaz ,

 

Yes I know, we can return back the custom response through scripted web service, but I want to know, how we can do the same with REST API - Asynchronous Inbound flow?

I would imagine that there is similar possibility, in a same action that you handle the inbound.

BUT, i dont have experience on it.

Yes, I am also looking for that. Thanks for the help.