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

No I am trying to access a third party server installed in LAN using midserver.And the communication without midserver is not possible


If the communication is through the midserver, the call & response will be in the ECC Queue.   Look in there to see how both were built.


Hi Eswari,



It could be timing out. Can you try increasing the timeout using the waitforresponse api to see if it works?


http://wiki.servicenow.com/index.php?title=RESTResponseV2_API#waitForResponse.28Number_timeoutSecs.2...


sanjay36
Tera Expert

Hey eswari,

 

I found this article when i had the same issues. I think this happens if you are using a mid-server to pass your REST requests to access the data which is lying in a local server applications.

can you try adding this script :

var k = 1;
            while ( response == null ) {
                gs.info( " waiting ... " + k + " seconds");
                response = r.getResponse(1000);
                k++;
                if ( k > 30 ) {
                    gs.info(' service time-out');
                    break;
                }
            }

https://community.servicenow.com/community?id=community_question&sys_id=22f647e5db1cdbc01dcaf3231f9619c0