HTTP Request needs Proxy Authentication

An update, I’ve managed to used the Incoke Code activity to use VBNet code, to call one of our APIs (a GET request). Below is the code:

Dim fr As System.Net.HttpWebRequest
Dim targetURI As New Uri(strURL)

fr = DirectCast(HttpWebRequest.Create(targetURI), System.Net.HttpWebRequest)

Dim webProxy As IWebProxy = New WebProxy(strIpAddressAndPort)
webProxy.Credentials = New NetworkCredential(strProxyUsername, strProxyPassword)
fr.Proxy = webProxy
fr.Credentials = New NetworkCredential(strSimpleAuthUsername, strSimpleAuthPassword)

Dim username As String = strSimpleAuthUsername
Dim password As String = strSimpleAuthPassword
Dim encoded As String = System.Convert.ToBase64String(Encoding.GetEncoding(“ISO-8859-1”).GetBytes(username + “:” + password))
fr.Headers.Add(“Authorization”, "Basic " + encoded)

Dim res As HttpWebResponse = DirectCast(fr.GetResponse(), System.Net.HttpWebResponse)
webRes = res

Dim html As String = New StreamReader(res.GetResponseStream()).ReadToEnd()
strHtml = html


Some notes:

strProxyIpAddressAndPort is in the form: IpAddress:PortNumber e.g. 192.168.1.1:8080
strURL is the API endpoint
strURL, strIPAddressAndPort, strProxyUsername, strProxyPassword, strSimpleAuthUsername, strSimpleAuthPassword are In Arguments
webRes and strHtml are Out Arguments


I tried to use similar code (but adding additional headers and code) in another API call for a PUT request, but that’s giving me the 403 error (Forbidden). We ended up not having to use this Environment for our application since it’s only in this environment where proxy authentication is needed.

Hopefully this helps someone that is having a similar issue. Cheers!