- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 01:23 PM
Hello all,
I'm working on a system integration with a third party. I have created a web service and transform map in our DEV instance, and we're able to receive and process inbound POSTs with bodies like this:
{
"u_number":"INC7654521",
"u_location":"HQ",
"u_cmdb_ci":"Toaster"
}
However, the third party would like to standardise their outbound messages to have bodies like this:
{
"incident":{
"u_number":"INC7654521",
"u_location":"HQ",
"u_cmdb_ci":"Toaster"
}
}
So, the JSON in my first example itself becomes the value of a field called "incident" in my second example. This doesn't work for the web service I've created, which has field names 'u_number', 'u_location, and 'u_cmdb_ci', and I guess in the second example the message is 'looking for' a field named 'incident'.
What are my options for processing the inbound message in the second case? I'm thinking I may have to write a script to place each inner field value onto the input row to trigger the transform map, but I would like to know what ya'll think.
Jamie.
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2018 11:17 AM
You can construct the response body in the Scripted rest api script as below
var body = {}; body.name = "incident"; body.number = "1234"; body.caller = {"id": "user1"}; response.setBody(body);
reference: https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 01:50 PM
You can actually access it using incident.u_number or incident.u_location in JSON.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2018 07:12 AM
Hi Sanjivmeher,
Thanks for your reply. Would I need to create a new endpoint and a script to grab the value of each field such as incident.u_location and use those values to create a a new row on the original table?
Jamie.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2018 08:39 AM
If you are already using scripted rest API, you just need to change your script.
If you are using table rest api, you will have to create a scripted rest api instead and use that.
Can you show me how you have created the REST API now?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2018 09:03 AM
Hi Sanjivmeher,
I have so far set up a table REST API with a transform map. But my issue is that the third party need to standardise their outbound messages. So I can see that I will need to use a scripted REST API. This will be OK, but I still want to be able to make use of all the logic I've included in my transform map. So my idea is, in the scripted API, grab all the field values and first map them to fields on my original REST table, so that the transform map runs. Does that sound sensible?
Jamie