How to get the response status_code number for an inbound REST service

dp11
Tera Guru

Hi,

 

We have data coming from an external service to our import set staging table via REST POST. The response will contain the status code of 200, 201, 400, etc. Can we access this status code via some script? We would like to create an INC for ourselves if we find an error status code in the response. 

 

Thanks,

DP

1 ACCEPTED SOLUTION

Animesh Das2
Mega Sage

Hi @dp11 ,

 

I don't think it is possible to get the status code as the target system in REST framework. The status code is meant for the source system, who is sending the request, as part of response to know whether the request got processed successfully.

For the target system, which is ServiceNow in this case, you need to verify the success of an incoming request based on records' update or insert in the stage or target table.

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

View solution in original post

4 REPLIES 4

Animesh Das2
Mega Sage

Hi @dp11 ,

 

I don't think it is possible to get the status code as the target system in REST framework. The status code is meant for the source system, who is sending the request, as part of response to know whether the request got processed successfully.

For the target system, which is ServiceNow in this case, you need to verify the success of an incoming request based on records' update or insert in the stage or target table.

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

Ankur Bawiskar
Tera Patron
Tera Patron

@dp11 

so 3rd party is consuming import set API and you want to know the status code?

As far as I know, the status codes are standard HTTP Response Codes defined at the platform layer. They are not configurable or overriding.

You can try to use Scripted REST API but I haven't tried using that with status code.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@dp11 

Thank you for marking my response as helpful.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader