HTTPS GET requests

Jester28

New Member
Joined
Apr 6, 2014
Messages
8
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:
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
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,215,388
Messages
6,124,641
Members
449,177
Latest member
Sousanna Aristiadou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top