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

Scripted REST API - Async response??

Sam10
Tera Expert

Hi Team, 

 

We have a requirement sent out by a company that our ServiceNow instance is being integrated with for the incident module that says each time an incident is created (after an event is triggered in the source instance), it should return an asynchronous response with the incident number created in our end + the incident number (originated incident) in their end. I have already added to my scripted rest API to send incident number created in our end with it's sys_id but apparently they need that and the asynchronous response mentioned above. 

 

Can someone please give me a guideline as to how to achieve this? can we only send out one acknowledgement after the incident is created in our environment through the rest API? 

 

 

Thanks,

Sam

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@Sam10 Instead of sending the response instantly, you can choose to create the incident locally first and later on sync the details with your third party server via any one of the following approaches.

1. Make an API call to your third party server from an async business rule and sync the data.

2. Create a scheduled job which syncs the data with third party server on a periodic basis.

3. Trigger an event from your business rule once a new incident from a third party is created, create a script action which calls the third party API asynchronously and syncs the incident data.

 

Hope this helps.

Vijay Balotia1
Tera Guru

Hi @Sam10,

 

If you are using Integration Hub you can use Async Rest and share the API detail with other team for you inbound integration. Also in the same flow you can create and incident using flow action based on your validation. 

Using this approach third party will only get the execution ID when they Hit your API. 

Later on when ever you want to send them the acknowledgement with the incident number created in our end + the incident number (originated incident) in their end. you can  create another flow/subflow to call there api for acknowledgement can trigger that from your BR or schedule when you want using below api's.

 

startActionQuick(), startFlowQuick(), startSubflowQuick(): Run an action, flow, or subflow from a server-side script asynchronously.

for more detail you can refer the below product document

https://docs.servicenow.com/en-US/bundle/sandiego-application-development/page/administer/flow-desig...

 https://docs.servicenow.com/en-US/bundle/rome-application-development/page/app-store/dev_portal/API_...

 


Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks
Vijay Balotia