Seemingly Slow Responses w/ Integrations over MID Server

SNOWman2
Mega Sage

I'm using RESTMessageV2 to send outbound REST messages to a client API via the MID Server. The average time for the call is 1.5 seconds and the client has some concerns about this because it's used to prepopulate data onto a form. 

 

When I look at the MID Server logs, the actual execution time is small, usually around 100ms. And the input w/ payload is usually created and on the ECC queue within 600ms. The remaining time to me doesn't make sense and need some help figuring out if this is improvable. Any thoughts? Previous experiences that can help? Thank you.

3 REPLIES 3

jaheerhattiwale
Mega Sage
Mega Sage

@SNOWman2 can you please share the code?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Something as straightforward as this: 

 

var request = new sn_ws.RESTMessageV2();

var xxxInputs = {
"xxx": "xxx",
"xxx": "xxx",
"xxx": "xxx"
};

var r = new sn_ws.RESTMessageV2();

r.setEndpoint("https://xxxxx.com:xxx/xxx/xx/xxxxx");
r.setMIDServer('Integrations-xxx-xx-xx');
r.setHttpMethod("post");

r.setRequestHeader("xxx", "xxxxx");
r.setRequestHeader("xxx", "xxxx");
r.setRequestHeader("xxx", "xxxx");
r.setRequestHeader("Content-Type", "Application/json");
r.setRequestHeader("xxx", "xxxx");
r.setEccParameter('skip_sensor', 'true');

r.setRequestBody(JSON.stringify(xxxInputs));

var response = r.executeAsync();
response.waitForResponse(60);

@SNOWman2 the first line is not needed as you are initialising it again.

 

And as the response is fast we don't need to wait for response and execute it in async. So try below code.

 

var xxxInputs = {
"xxx": "xxx",
"xxx": "xxx",
"xxx": "xxx"
};

var r = new sn_ws.RESTMessageV2();

r.setEndpoint("https://xxxxx.com:xxx/xxx/xx/xxxxx");
r.setMIDServer('Integrations-xxx-xx-xx');
r.setHttpMethod("post");

r.setRequestHeader("xxx", "xxxxx");
r.setRequestHeader("xxx", "xxxx");
r.setRequestHeader("xxx", "xxxx");
r.setRequestHeader("Content-Type", "Application/json");
r.setRequestHeader("xxx", "xxxx");
r.setEccParameter('skip_sensor', 'true');

r.setRequestBody(JSON.stringify(xxxInputs));

var response = r.execute();

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023