Get rid of the "result" node from Rest API Response
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 07:37 AM
I have the same question as this one https://community.servicenow.com/community?id=community_question&sys_id=058e4b21dbdcdbc01dcaf3231f96...
It's been 6 years since that was posted and I wanted to know if there's an easier way to remove the "result" wrapper from responses now than for me to build out response objects for each and every type of request I send to a third party service.
Labels:
- Labels:
-
Scripting and Coding
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2022 04:03 AM
Hi BP,
Try following script.
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
response.setHeader('Content-Type', 'application/json');
var resultObj = {
"text": "Hello world!"
};
writer = response.getStreamWriter();
writer.writeString(JSON.stringify(resultObj));
})(request, response);
Result