I am running the following code in 4 computers:
The code makes a simple HTTP request to a target server using POST.
Sub test()
valueParam1 = "value1"
valueParam2 = "value2"
user = "myUser"
pass = "myPass"
headerName = "Content-Type"
headerValue = "application/x-www-form-urlencoded"
Url = "https://www.myURL.com" + "/Path1/Path2/File.php?"
Set htttpObj = CreateObject("WinHttp.WinHttpRequest.5.1")
htttpObj.SetTimeouts 10000, 10000, 10000, 300000
htttpObj.Open "POST", Url, False
htttpObj.setRequestHeader headerName, headerValue
htttpObj.Send ("param1=" & valueParam1 & "¶m2=" & valueParam2 & "&username=" & user & "&psd=" & pass)
response = htttpObj.responseText
End Sub
2 out of 4 computers run the code perfectly.
2 out of 4 computers show the following error message:
Run time error: -2147012867
The computers that run the code are using Windows10 version 10.0.14393
The computers that do not run the code use Windows7 version 6.1.7601, Service Pack 1
This error only happens after I edit the following file:
C:\Windows\System32\drivers\etc\hosts
I add the following information to the file to change the IP address of the hostname 'myURL.com':
149.56.23.106 myURL.com
149.56.23.106 www.myURL.com
Any ideas on how to investigate or solve this problem?