Return HTTPStatusCodes when calling a script

Hi.

I have a script that when successful returns a json with relevant information when called from ServiceNow. Is there a way to send different HTTPStatusCodes depending on how successful the script is?

Example 1:

Script is successful and returns 200 OK and the result or 204 NoContent with no result

Example 2:

Sciprt is unsuccessful and returns 409 Conflict.

/Henrik

PS. I'm running Identity Manager 9.2

Parents
  • I am assuming you are calling the script via the REST API from the Application Server. If that is the case, then the answer is no, you cannot configure or customize the HTTP return codes from the REST API Call. 

    You can try to return JSON Strings from the script that contain your desired HTTP Status. But the returned JSON needs to be parsed by ServiceNow then.

Reply
  • I am assuming you are calling the script via the REST API from the Application Server. If that is the case, then the answer is no, you cannot configure or customize the HTTP return codes from the REST API Call. 

    You can try to return JSON Strings from the script that contain your desired HTTP Status. But the returned JSON needs to be parsed by ServiceNow then.

Children