- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 08:17 PM
Hello everyone,
I am working on the use case in which third party system is going to send us the JSON formatted data and I need to receive the data at ServiceNow and load the data to target tables using the data import function.
This is my approach: Accept the JSON payload->Create the DataSource using the staging table and associated transform->Load staging tables->run transforms. So, everything works as expected but I want to return response as soon as JSON payload is received, and then continue the data import using the functions/script includes.
How can I return the response and continue the data processing for scripted rest API.
Thanks in advance,
Rahul
Solved! Go to Solution.
- Labels:
-
Platform and Cloud Security
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2020 09:46 AM
Hi Rahul,
Basically this is the approach you can have;
I believe the data load, transform etc needs to happen asynchronous
1) create event
2) create script action associated to this event
3) in the scripted rest api script call the event and pass the entire json object you received
4) script action will then accept the value and do whatever you want to do i.e. insert data into import set table and then it would trigger the transform
5) Once you call the event using eventQueue() send the response to 3rd party about whatever status you want
Script Action:
Sample Script: Rest API Script
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var reqbody = request.body.dataString;
gs.eventQueue('event_name', null, reqbody,'');
// send response
return {
"status": success
};
})(request, response);
Script Action Script:
var dataString = event.parm1; // this will contain the entire request body sent
// now parse this json and do whatever is required
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2020 11:17 AM
ServiceNow REST provides executeAsync() method to handle your requirement.
Check below for more details
https://hi.service-now.com/kb_view.do?sysparm_article=KB0694711
https://hi.service-now.com/kb_view.do?sysparm_article=KB0716391
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 09:11 PM
Hi Sachin,
It wouldn`t work as my use case is of inbound REST message.
Thanks,
Rahul