HTTP Request working in browser/postman but incorrect response in Autohotkey Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Yogi
Posts: 12
Joined: 06 Jul 2022, 23:03

HTTP Request working in browser/postman but incorrect response in Autohotkey

22 Aug 2022, 23:17

With any browser or the program postman, I'm able to get a response from the following URL with no headers specified:

https://api.nasdaq.com/api/ipo/calendar

However when I try it with autohotkey, I get NO response.

If I include the following headers:

Code: Select all

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")				 						 		
whr.Open("GET", "https://api.nasdaq.com/api/ipo/calendar" , false)												;	   Nasdaq IPOs		
whr.Send()
I get a Response that states "?"


I'm sure I am doing something incorrectly, if anyone has any experience or can help me get the correct response which is a JSON with the new IPOs I'd greatly appreciate it. Thank you.
Last edited by Yogi on 20 Sep 2022, 22:05, edited 1 time in total.
Yogi
Posts: 12
Joined: 06 Jul 2022, 23:03

Re: HTTP Request working in browser/postman but incorrect response in Autohotkey

23 Aug 2022, 00:48

BoBo wrote:
23 Aug 2022, 00:30
AFAICS you need an API key setting too, isn't it so? :think:
https://docs.data.nasdaq.com/docs/getting-started
https://docs.data.nasdaq.com/docs/in-depth-usage

BTw, The response that I get with your code: 謟
That is a strange reponse hah. I have an API key but it doesn't seem to work with it either.

I don't think the API key is necessary for this request.

If i open that link without any API key in any browser it will show the data. Even in postmaster. It's just that I don't get the same response with autohotkey.

EDIT:

I have managed to get it working using:

ComObjCreate("Msxml2.XMLHTTP")
Instead of
ComObjCreate("WinHttp.WinHttpRequest.5.1")

That's with no cookies or RequestHeaders (or api keys). I don't know why it works using that but not the WinHttp.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: HTTP Request working in browser/postman but incorrect response in Autohotkey  Topic is solved

23 Aug 2022, 03:17

whr.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")
Some quick searching indicates that WinHttpRequest doesn't support gzip, or at least doesn't decode it automatically.
Yogi
Posts: 12
Joined: 06 Jul 2022, 23:03

Re: HTTP Request working in browser/postman but incorrect response in Autohotkey

23 Aug 2022, 03:28

lexikos wrote:
23 Aug 2022, 03:17
whr.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")
Some quick searching indicates that WinHttpRequest doesn't support gzip, or at least doesn't decode it automatically.
That's the ticket! Thank you!
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: HTTP Request working in browser/postman but incorrect response in Autohotkey

23 Aug 2022, 05:19

Yep, that's doing it...

Code: Select all

#SingleInstance, Force
whr := ComObjCreate("Msxml2.XMLHTTP")			 						 		
whr.Open("GET", "https://api.nasdaq.com/api/ipo/calendar" , false)
whr.Send()
MsgBox % whr.ResponseText

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Rxbie and 237 guests