Dynamic Json payload construction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 02:03 PM
Hi,
I am integrating Servicenow instance with other tool.
the payload which I have to send from Servicenow to other tool can be fetched by a rest call and I am storing this in a rest message and giving some inputs to some variables by setstringparameter in business rule.
so only once I am fetching the payload through background script and storing the payload in rest message and using this when ever user wants to raise a ticket in other tool , by modifying the values in that payload based on users input and sending it to other tool via rest .
but now tool configuration has changed , they payload which I stored in rest message will no more work as there are some changes in tool. So , client requested to pull payload every time or for every day and then store it in rest message and use it , but this cannot be done manually . So how do it modify json content ? For now I am using setstringparameter, and ${} in payload,... but if payload is pulled everyday , it’s difficult to replace this.
- Labels:
-
IntegrationHub
-
Orchestration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 03:34 PM
In that case I would say dont user REST message but directly initiate a REST call in your script.
You can do that like this-
var sm = new sn_ws.RESTMessageV2();
sm.setEndpoint("http://web.service.endpoint");
For more information check documents-
https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/r_RESTMessageV2_setEndpoint_S...
So in your script first you will fetch the payload (I assume its JSON), convert it to JSON object, add user inputs in the JSON, and set it request body.
-Tanaji
Please mark response correct/helpful if applicable