Abhishaik Srivastava
New Member
I have a requirement to connect to public website that is REST enabled and get the data using VBA. I am able to achieve the same but it is only running in my home network. Whenever I am connected to office network, it is not able to connect to the server. I tested the same with ping command also i.e. whenever I am in my home network, I get ping response from the server, but whenever I tried to do the same from office network, it says server not reachable. I am assuming that it is proxy issue i.e. from office network, it requires proxy to reach out public website.
I have following code snippet that is working well in my home network
I am not an expert in VBA, so looking out for help. I tried to find multiple options from internet for proxy setting for "WinHttp.WinHttpRequest.5.1", but didn't find the concrete one.
Found example for "ServerXMLHTTP60", but it requires to import the module.
Is there anyway to set the proxy correctly before sending the request. It is not a proxy IP, but a proxy script that I need to set.
I have following code snippet that is working well in my home network
Code:
Function getData(url As String) As Object
Dim JsonText As String
Dim MyRequest As Object
Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
MyRequest.Open "GET", url, False
MyRequest.SetRequestHeader "ZSESSIONID", MyApiKey
' Send Request.
MyRequest.send
'And we get this response
JsonText = MyRequest.responseText
Set getData = JsonConverter.ParseJson(JsonText)
End Function
Found example for "ServerXMLHTTP60", but it requires to import the module.
Is there anyway to set the proxy correctly before sending the request. It is not a proxy IP, but a proxy script that I need to set.