[MID Server Script Include] How to make rest calls using Packages.com.glide.communications.HTTPRequest through a proxy ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2018 03:26 AM
I am using the Packages.com.glide.communications.HTTPRequest object to make HTTP calls as follows
this.GlideHTTPRequest = Packages.com.glide.communications.HTTPRequest;
var request = new this.GlideHTTPRequest(<URL>);
request.addHeader(<headerKey>, <header>);
request.post(JSON.stringify(<body>));
Now I want to make the same HTTP calls through a proxy.
How do I set proxy parameters for this HTTPRequest object ?
I've figured out that the HTTPRequest has the following methods which seems useful:
- upProxy
- upProxyUsernamePassword
- setupProxy
- setupProxyUsernamePassword
But I do not know how to use them and neither am I sure that these methods are the way to go. Can anybody help me out ?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2018 02:46 PM
If you're on a MID already why not use a technology you are more familiar with?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2020 05:39 AM
Hi,
May be its a late reply, but here is how you get proxy info at MID side
var Instances = Packages.com.service_now.mid.services.Instances;
var instance = Instances.get().getPrimaryInstance();
var proxyHost = instance.getProxyHost();
var proxyPort = instance.getProxyPort();
var proxyUsername = (instance.getProxyUserName() != null ? instance.getProxyUserName() : "");
var proxyPassword = instance.getProxyPassword();
then use these
request.setupProxy(proxyHost, proxyPort);
//for domains
request.setupNTLM(userName, proxyPassword, proxyHost, domainName);
//otherwise
request.setupProxyUsernamePassword(proxyUsername, proxyPassword);