Rest Message returns null

eswarijk
Tera Contributor

I am calling a third party API with the help of Rest message.

I have written the rest message script in a script include.

That script include function will be called periodically using scheduled script execution.

Mostly I am getting the response correctly but sometimes it fails.

Sometimes, calling the rest messagev2 script returns null as response body with 200 response status

Can anyone explain me the solution for this problem ?

8 REPLIES 8

Chuck Tomasi
Tera Patron

Before you get down in to the details, have you tried using something like Postman to verify the results? It sounds like you may be missing a parameter (either in the URI or request body) that the remote system has not processed so it has nothing to respond back with. For example "Tell me the weather forecast..." but you didn't say for what day or location, it could simply be returning nothing with a 200 status "OK, here's nothing since you asked for nothing." Check the API closely on the remote system and test with a simple tool like Postman before building out in ServiceNow.



My most common issues have been forgetting to send the right request headers (e.g. Content-type: application/json, or Accept: application/json) to get the proper response back.


Yes , I tried it with Postman and it is working correctly there.


Even I tried using 'Test' link in ServiceNow Rest Message and it is returning correct data.



The Parameters and headers are correct because I am getting correct response all the times.


This problem is occurring when calling the script include function from a scheduler.


And this null response is obtained only few times.


eswarijk
Tera Contributor

I am using midserver to contact Third party API ....


Whether there is any communication issue?


The MID server COULD have something to do with it. I haven't heard of this before, but I don't do many integrations through a MID server these days. Is it possible to try it without the MID server as a test?