Seemingly Slow Responses w/ Integrations over MID Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 05:04 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 06:44 PM
@SNOWman2 can you please share the code?
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 06:49 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 07:24 PM
@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.
ServiceNow Community Rising Star, Class of 2023