Scripted REST API not processing status code 500
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2021 09:21 AM
Hi,
I have created a scripted REST api which sends status code 500 in case of error.
But when some response is sent with status code 500 , Response body does not show the correct format , instead it shows on html saying "Instance Unavailable"
var processError = new sn_ws_err.ServiceError();
processError.setStatus(500);
return processError;
In response:
Status code
500 Internal Server Error
Response Body:
"<!DOCTYPE html>\n<html>
<head>
.
.
<title>Instance Unavailable</title>
.
.
< Service Interruption - This instance is unavailable
.
If service does not restore promptly, please open a Case in the ServiceNow HI Service Portal or contact Technical Support
.
.
"
-----------------------------------------------------------------------------------------------------------------------------------------------
If I change status code to 400 , I get correct response with response body.
Status code
400 Bad Request
Response Body:
{
"error": {
"message": "",
"detail": ""
},
"status": "failure"
}
Is this issue because of Instance or API, Please let me know how to fix this.
Thanks
Deepak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2021 11:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2021 04:08 AM
Hi Balaji,
I tried this setMessage, setDetails but getting same error, It is working if I change status code from 500 to 400 or 550.
Thanks
Deepak