- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2022 08:53 PM
I have created a Scripted Rest API which generates a response, how to send the response to another Scripted Rest API
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2022 09:04 PM
Hi,
Scripted REST API would return the response to the external application which has consumed the ServiceNow Endpoint.
you can consume API and send that response as request body
Regards
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-06-2022 09:04 PM
Can you please explain complete use case?
To which API you want to send the response and from where?
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2022 09:16 PM
I am trying to send response from Scripted API to another Scripted API [my custom api]
Is this the right way to send response
try {
var json = new JSON();
var jsonObj = json.encode(result_arr);
gs.log("JSON" + jsonObj);
var rm = new sn_ws.RESTMessageV2();
rm.setEndpoint('my custom api url');
rm.setHttpMethod('POST');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';
rm.setBasicAuth(user, password);
rm.setRequestHeader("Accept", "application/json");
rm.setRequestHeader('Content-Type', 'application/json');
rm.setRequestHeader("Accept", "application/json");
rm.setRequestBody(jsonObj);
var response1 = rm.execute();
responseBody=response1.getBody();
gs.log(response1.getBody());
status1 = response.getStatusCode();
} catch (ex) {
errorMsg = ex.getMessage();
status1 = '500';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2022 09:04 PM
Hi,
Scripted REST API would return the response to the external application which has consumed the ServiceNow Endpoint.
you can consume API and send that response as request body
Regards
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-06-2022 09:18 PM
Can you please share sample documentation or an example on how to consume API and send that response as request body