vbawinhttprequest

WinHTTP Request fails (timeout). Why?


So, I'm trying to send a request to a http server from VBA using the WinHttpRequest class.

I've already made a similar code which sends requests to another server, and it worked. This one won't even go through the ".Send". It fails (timeout).

I've checked every RequestHeader at Google Chrome devtools and tried to replicate the web request, but failed (with and without the cookies).

Any ideas?

The code:

    Dim WHTTP As New WinHttp.WinHttpRequest

    With WHTTP
        .Open "GET", "https://contactcenter-prd.prosodie.com/prweb/sso", False
        .SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
        .SetRequestHeader "Accept-Encoding", "gzip, deflate, br"
        .SetRequestHeader "Accept-Language", "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7"
        .SetRequestHeader "Connection", "keep-alive"
        '.SetRequestHeader "Cookie", "JSESSIONID=337C72E2DBCC1080C674033FFC51EBFA.contactcenter; Pega-RULES=" & Chr(34) & "{atn}e3ByfVkzNDBlc3NYRlBYdWFRT2dkRFRjekU5LytjNm51MEMwazI4YmJqVDNvaFlUTE1LQUN3T1p6SUVYMEd5dlUxaHRSWEVINFpJTWVhY1YKdCtpRkQwZjJLdz09" & Chr(34) & "; BWROUTEID=s2ac70d938fbd5ee39c5b1b93ac33d7b.1"
        .SetRequestHeader "Host", "contactcenter-prd.prosodie.com"
        .SetRequestHeader "Upgrade-Insecure-Requests", "1"
        '.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36" ' From Chrome
        .SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" ' Some guy said it would work (it didn't)
        '.SetTimeouts 1200000, 1200000, 1200000, 1200000
        .Send
    End With

EDIT:

The purpose of the macro is to enter the website, get some info, put the info into a worksheet and exit the website.

I'm aware that the URL redirects to another, but (I think) I have to go to the first website to get some cookies.

EDIT 2:

Problem solved.

I had to setup a proxy to use the website. .SetProxy 2, myProxy did the trick!


Solution

  • The problem was solved by using .SetProxy 2, proxy.