- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 02:42 PM
Hi,
My requirement is to get the message and type from the response body. When I get status code 500, this is the response body I have. I am using the script include for calling the rest API and then calling this API in one of the UI actions. So I need to show this message and type I get in my response body when I click the UI action.
ResponseBody:
{
"error" : {
"type" : "SERVICE_EXCEPTION",
"message" : "MTA may be in use and determined to be not safe to suspend."
}
}
Any help would be appreciated!
Thanks,
Su
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 05:00 AM
Cool. Can you now replace
type = res.type;
message = res.message;
with
type = res.error.type;
message = res.error.message;
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 04:35 AM
please replace
var httpStatus = res.getStatusCode();
with
var httpStatus = response.getStatusCode();
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 04:45 AM
I replaced as you said. The output is:
Su response - [object Object]
Su message - undefined
Su type - undefined
Su Status- 500

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 05:00 AM
Cool. Can you now replace
type = res.type;
message = res.message;
with
type = res.error.type;
message = res.error.message;
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 05:17 AM
Perfect! this works like a charm!
Thanks a lot.. 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 05:28 AM
Glad It worked. Happy coding!
Thanks & Regards,
Sharjeel
Muhammad