How to send a JSON object content in POST API - OUTBOUND call from servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 04:54 AM
Hi Team,
I am doing an oAuth 2.0 integration between servicenow and 3rd party tool.
I am able to get the access token via the script successfully.
Then i need to pass this token as a header along with two other headers,which i am able to:
accept : application/json
Content-Type : application/json
Authorization : Bearer $token
My ask is how to send the payload in the script ???????
The payload is a JSON object and I am not sure how to send it across to other tool.
{
"first_name": xxxx,
"last_name": "xxxxxxx",
"reason_name": "TESt",
"ip_address": "1xxxxx",
"net_mask": xxxxx
}
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 05:06 AM
In your outbound REST method under the HTTP Request tab, add the JSON in the content box.
{
"first_name": "${first_name}",
"last_name": "${last_name}",
"reason_name": "${reason_name}",
"ip_address": "${ip_address}",
"net_mask": ${net_mask}
}
Then, at the bottom of the page, use the related link "Auto-generate variables" to create the variables and populate test values if you need to test.
Then use the "Preview Script Usage" related link to see how to make the call from a script using the parameters you just generated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:04 AM