JSON Format disappearing on transfer to import set using import set REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 06:56 AM
Hi,
We are using REST API to send data from Point a to b(servicenow target table).
we are using Import set web service for validations. So basically getting data in JSON format from source a and sending it to the import set using REST API wherein we will use transform map to map data to the target table.
SO, for sending data, In the REST API we are setting the endpoints(to import set), httpmethod(POST), authentication and the setting the body with the JSON string(received from source a).
Like:
var str = {"u_data":{"Company":"XYZ","Location":"ABC"}} // JSON string received from source a
request.setRequestBody(str); //sending to import set
But I'm receiving this data in the import set table field(u_data) in the below format:
Company=XYZ,Location=ABC
so basically the data I'm receiving changes colon to equal sign and I'm not able to parse or stringify this data as it is not in valid JSON Format.
has anyone worked on a similar thing who could help me to get the data in JSON format in import set field or help me to convert the string to JSON.
Thanks
nisha
- Labels:
-
Best Practices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 09:07 AM
You need to pass the data value as string
Can you replace
var str = {"u_data":{"Company":"XYZ","Location":"ABC"}} // JSON string received from source a
with
var str = {"u_data":'{"Company":"XYZ","Location":"ABC"}'} // JSON string received from source a

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 09:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 12:09 AM
Hi Nishtha,
You can create a business rule on the import set table and write below script.
var initialJsonFormat=current.yourfieldname;
var massagingStageValue=initialJsonFormat.replace(/=/g,':');
current.yourfieldname=massagingStageValue;
current.update();
Please mark correct. if it helps you.
Regards,
Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 11:13 PM
Hello everyone,
Using toSring() on the incoming payload changed it to string and then we could parse the data and send.
var str = {"u_data":{"Company":"XYZ","Location":"ABC"}} // JSON string received from source a
var strg = str.toString();
Nisha