- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2017 12:05 PM
Any help? I am doing an outbound REST call through my MID Server to get user pictures. I can verify that I get a successful response until I add a saveResponseBodyAsAttachment statement to my script. With that statement I always get the following error:
- java.net.SocketTimeoutException: connect timed out when posting to https://xxx.service-now.com/api/now/v1/attachment/file
Here is my script (with private data removed) -
var user = new GlideRecord('sys_user');
user.addQuery('xxx','xxxxxxxx');
user.query();
if(user.next()) {
try {
var token = '';
var s = new sn_ws.SOAPMessageV2('xxxxx', 'xxxxx');
s.setStringParameterNoEscape('userId', 'xxxxx');
s.setStringParameterNoEscape('credential', 'xxxxxx');
var responseS = s.execute();
var responseBodyS = responseS.getBody();
var xmlDoc = new XMLDocument(responseBodyS.toString(), true);
var token = xmlDoc.getNodeText("//authenticateReturn");
var r = new sn_ws.RESTMessageV2('User Photos', 'Get User Picture');
r.setStringParameterNoEscape('cookie', 'xxxxxx' + token);
r.setStringParameterNoEscape('xxxx', user.xxx.toString());
r.saveResponseBodyAsAttachment('ZZ_YYsys_user', user.sys_id.toString(), 'photo', 'image/jpeg');
var response = r.execute();
gs.print(response.getStatusCode());
gs.print(response.getErrorMessage());
}
catch(ex) {
gs.print('Got an exception: ' + ex.getMessage());
}
}
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 07:55 AM
After a lot of testing, an incident with ServiceNow, and a wireshark I found the issue. My outbound REST call uses a MID Server to get to our internal picture server. Our MID server has to use a proxy to get from the MID to our instance. What I've found is that the saveResponseBodyAsAttachment() method is attempting to go straight from the MID server to our instance. It is not using the MID server's defined proxy.
Unfortunately, there isn't a way for me to add an option or configure it to use the proxy. I've asked for a problem ticket or enhancement request from ServiceNow to have saveResponseBodyAsAttachment() use a defined proxy when a MID server is used.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2017 01:58 PM
What is the End point for the REST. Is it active directory. There could be an issue in REST API exposed by the external system.
Are they getting any error?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2017 02:05 PM
Thanks.
I don't get an error from my REST call. And, if I remove my
saveResponseBodyAsAttachment() and just use gs.print(response.getBody()),
I get the binary text of the image file. So, the REST call works. It is
the saveResponseAsAttachment that is failing.
Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 07:55 AM
After a lot of testing, an incident with ServiceNow, and a wireshark I found the issue. My outbound REST call uses a MID Server to get to our internal picture server. Our MID server has to use a proxy to get from the MID to our instance. What I've found is that the saveResponseBodyAsAttachment() method is attempting to go straight from the MID server to our instance. It is not using the MID server's defined proxy.
Unfortunately, there isn't a way for me to add an option or configure it to use the proxy. I've asked for a problem ticket or enhancement request from ServiceNow to have saveResponseBodyAsAttachment() use a defined proxy when a MID server is used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2017 01:52 PM
I have the exact same problem.
Do you have a feedback from ServiceNow on that? What's the status of the PRB?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:40 AM
I haven't seen any movement on the problem ticket yet. (PRB1028554)