The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to send a JSON object content in POST API - OUTBOUND call from servicenow

Shraddha Agrawa
Tera Contributor

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
}

 

 

2 REPLIES 2

_ChrisHelming
Tera Guru

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.

Hi @Chris Helming , thanks a lot for the reply.I am still facing the below error. can u please help.

 

find_real_file.png