0

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!

Julio Hintze
  • 128
  • 2
  • 11
  • This URL redirects to `https://extranet-logon-emea.sanofi.com/my.policy` with login form. Are you trying to log in? Give us full picture. – JohnyL May 23 '18 at 20:08
  • Sorry about being a little vague. I've updated the original post. – Julio Hintze May 24 '18 at 15:47
  • There's a need for login and password :) – JohnyL May 24 '18 at 16:46
  • The request should give me a html page with the login/password inputs, but the "Send" method always timesout – Julio Hintze May 24 '18 at 17:22
  • Use [Postman](https://www.getpostman.com) or [Fiddler](https://www.telerik.com/fiddler) to see what's going on. – JohnyL May 24 '18 at 18:11
  • Solved it! Thank you, JohnyL, for the patience! – Julio Hintze May 25 '18 at 14:28
  • Glad that helped you :) – JohnyL May 25 '18 at 17:31
  • @JulioCesarHintzedosSantos Thanks for posting the solution line. Would you mind posting it as an answer rather than an edit to the question please? If you post the line added to your original code it will not only help others more, but may earn you rep points. Two days after posting your answer you can then accept it. – QHarr May 28 '18 at 17:35

1 Answers1

1

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

Julio Hintze
  • 128
  • 2
  • 11