how to send outbound Request n JSON format in REST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 01:08 AM
Hi All,
I have created REST Outbound Message. I am able to recieve response in JSON format, but I want to send the outbound request in JSONformat.
Please suggest.
Response:
Request:
Regards,
Sumit Jumale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 01:29 AM
Hi Sumit,
While sending a request in json format you can use REST API explorer and fill the required info. in fields.
Please see below screenshot how to send response in JSON format.
In request headers pass the request format value as application/json. So it will send a request in JSON format.
In below screenshot you can able to see request sent in JSON format.
Hope it will helps you.
Regards,
Swapnil
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 01:48 AM
Thanks for quick reply Swapnil.
I am send request outbound through code written in Business rule. In this case i can not use Rest API Explorer to send the request in JSON format.
Please suggest some way to send request through code in JSON format.
Regards,
Sumit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 02:09 AM
Hi Sumit,
You can refer below script in your Business rule.
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://your instance name.service-now.com/api/now/table/incident');
request.setHttpMethod('POST');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';
request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
var response = request.execute();
gs.log(response.getBody());
Use the above bold highlighted lines in your business rule.
Hope it will helps you.
Regards,
Swapnil
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 01:47 AM
Can I ask what you are trying to test, Scripted REST APIs or ? You can send request by REST message also.
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.