Hello,
I have a problem that I am fighting with for the last couple of days.
My problem is that I am trying to pull data from a website using HTTPS GET but the website requires a SessionID (cookie).
This is the request that I managed to catch with Fiddle2:
This is the code that I managed to create but each time I run it, the MsgBox shows : "ERROR: Invalid authorization" <- This means the cookie hasen't been sent or something (I guess)
P.S: I am using the reference for WinHTTPRequest5.1.1
I have a problem that I am fighting with for the last couple of days.
My problem is that I am trying to pull data from a website using HTTPS GET but the website requires a SessionID (cookie).
This is the request that I managed to catch with Fiddle2:
Code:
GET https://trading.xxxxxx.net/ws/search.json?ids=000000 HTTP/1.1
Host: trading.xxxxxx.net
Connection: keep-alive
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1003.1 Safari/535.19
Accept: */*
Referer: https://trading.xxxxxx.net/item/000000
Accept-Encoding: gzip,deflate
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
Cookie: s=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; s=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
This is the code that I managed to create but each time I run it, the MsgBox shows : "ERROR: Invalid authorization" <- This means the cookie hasen't been sent or something (I guess)
Code:
Private Sub UD_Button_Click()
Dim Http As New WinHttp.WinHttpRequest
Set Http = New WinHttpRequest
Http.Open "GET", "https://trading.xxxxxx.net/ws/search.json?ids=000000", False
Http.SetRequestHeader "Host", "trading.xxxxxx.net"
Http.SetRequestHeader "Connection", "Keep-alive"
Http.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
Http.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1003.1 Safari/535.19"
Http.SetRequestHeader "Accept", "*/*"
Http.SetRequestHeader "Referer", "https://trading.xxxxxx.net/item/000000"
Http.SetRequestHeader "Accept-Encoding", "gzip,deflate"
Http.SetRequestHeader "Accept-Charset", "iso-8859-1,*,utf-8"
Http.SetRequestHeader "Cookie", "s=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; s=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Http.Send
MsgBox Http.ResponseText
End Sub
P.S: I am using the reference for WinHTTPRequest5.1.1