Making HTTPS connections through proxy with authentication from MID Server Script Include

Marek Meres
Tera Expert

Hello Guys,

 

I need to transfer big files (100MB) from the MID server to the instance for loading and I am trying to find a solution. The preferred one would be using attachment API I guess. In my case the MID server is behind a proxy which requires authentication.

 

I investigated Remote File Importer (Import Files from a MID Server) - Share | ServiceNow Developers and found out it uses MID server's own connection parameters including proxy settings but does not use proxy authentication hence I am getting errors from proxy. Do you know how to add proxy username and password to the MID server script include?

 

I tried simply adding:

Packages.java.lang.System.setProperty("http.proxyUser", ms.getConfigParameter("mid.proxy.username"));
Packages.java.lang.System.setProperty("http.proxyPassword", ms.getConfigParameter("mid.proxy.password"));
Packages.java.lang.System.setProperty("https.proxyUser", ms.getConfigParameter("mid.proxy.username"));
Packages.java.lang.System.setProperty("https.proxyPassword", ms.getConfigParameter("mid.proxy.password"));

but it did not work.

 

Then I tried:

var proxyuserpass = new Packages.java.lang.String(ms.getConfigParameter("mid.proxy.username") + ":" + ms.getConfigParameter("mid.proxy.password"));
 var proxyAuth = "Basic " + (new Packages.javax.xml.bind.DatatypeConverter.printBase64Binary(proxyuserpass.getBytes()) + '');
conn.setRequestProperty("Proxy-Authorization", proxyAuth);   

 but again - no luck...

 

Thanks in advance!

1 ACCEPTED SOLUTION

Hi, This remote file importer may not be up to date, probably deploying it to the instance of latest releases is too risky

Appli_0-1709564383900.png

Downloading from MID server - consider another method - set up SFTP server on MID server' host and retrieve the file over data source of SFTP type.  Integration Hub (Pro or Ent) supports SFTP steps making it possible to use Flow Designer for SFTP operations.

 

Hope it helps

View solution in original post

9 REPLIES 9

Hi, This remote file importer may not be up to date, probably deploying it to the instance of latest releases is too risky

Appli_0-1709564383900.png

Downloading from MID server - consider another method - set up SFTP server on MID server' host and retrieve the file over data source of SFTP type.  Integration Hub (Pro or Ent) supports SFTP steps making it possible to use Flow Designer for SFTP operations.

 

Hope it helps

Many thanks Appli! 

 

Yes, this sounds as a good solution, much better than struggling with code and outdated APIs! I will investigate the details, but thank you very much for all your help already!

Hello Marek,

I did not get if your goal was to pass the proxy's user and password to the Script include ran by the MID Server. We did something passing them in the XML of the ecc_queue and reading these parameter from the Script Include ran by the MID Server, this way:

       this.KEY = probe.getParameter('myapp_key');
        this.SECRET = probe.getParameter('myapp_secret');

JosiahNunez
Giga Contributor

Dealing with proxy authentication for HTTPS connections from the MID server can be tricky. It's great that you're considering using the attachment API for transferring big files.

JosiahNunez
Giga Contributor

Dealing with proxy authentication for HTTPS connections from the MID server can be tricky. It's great that you're considering using the attachment API for transferring big files.To add proxy username and password to the MID server script include, you'll need to configure the proxy settings in your script. This typically involves setting the proxy server address, port, and credentials. Ensure that your script include includes the necessary proxy settings and credentials to authenticate with the server. This should help resolve the errors you're encountering.