WinHttpRequest (An error occurred in the secure channel support)

Get help with using AutoHotkey and its commands and hotkeys
User avatar
TheDewd
Posts: 1131
Joined: 19 Dec 2013, 11:16
Location: USA

WinHttpRequest (An error occurred in the secure channel support)

19 Oct 2018, 11:31

I'm trying to use WinHttoRequest with POST but I keep receiving the error "An error occurred in the secure channel support".

Any ideas?

Code: Select all

#SingleInstance, Force
#Persistent

Data := "companyName=&address1=1600+Pennsylvania+Ave+NW&address2=&city=DC&state=WA&zip=20500"

WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("POST", "http://tools.usps.com/tools/app/ziplookup/zipByAddress")
WebRequest.SetRequestHeader("Host", "tools.usps.com")
WebRequest.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0")
WebRequest.SetRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01")
WebRequest.SetRequestHeader("Accept-Language", "en-US,en;q=0.5")
WebRequest.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")
WebRequest.SetRequestHeader("Referer", "https://tools.usps.com/zip-code-lookup.htm?byaddress")
WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
WebRequest.SetRequestHeader("X-Requested-With", "XMLHttpRequest")
WebRequest.SetRequestHeader("Content-Length", StrLen(Data))
WebRequest.SetRequestHeader("DNT", "1")
WebRequest.SetRequestHeader("Connection", "keep-alive")
WebRequest.SetRequestHeader("Pragma", "no-cache")
WebRequest.SetRequestHeader("Cache-Control", "no-cache")

StrPut(Data, &Data, "", "UTF-8")

WebRequest.Send(Data)

Result := WebRequest.ResponseText

MsgBox, % Result

Code: Select all

---------------------------
New AutoHotkey Script.ahk
---------------------------
Error:  0x80072F7D - 
Source:		WinHttp.WinHttpRequest
Description:	An error occurred in the secure channel support


HelpFile:		(null)
HelpContext:	0

Specifically: Send

	Line#
	015: WebRequest.SetRequestHeader("X-Requested-With", "XMLHttpRequest")  
	016: WebRequest.SetRequestHeader("Content-Length", StrLen(Data))  
	017: WebRequest.SetRequestHeader("DNT", "1")  
	018: WebRequest.SetRequestHeader("Connection", "keep-alive")  
	019: WebRequest.SetRequestHeader("Pragma", "no-cache")  
	020: WebRequest.SetRequestHeader("Cache-Control", "no-cache")  
	022: StrPut(Data, &Data, "", "UTF-8")  
--->	024: WebRequest.Send(Data)  
	026: Result := WebRequest.ResponseText
	028: MsgBox,Result
	029: Exit
	030: Exit
	030: Exit

Continue running the script?
---------------------------
Yes   No   
---------------------------
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: WinHttpRequest (An error occurred in the secure channel support)

19 Oct 2018, 16:28

Code: Select all

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("POST", "https://tools.usps.com/tools/app/ziplookup/zipByAddress")
whr.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
whr.Send("companyName=&address1=1600+Pennsylvania+Ave+NW&address2=&city=DC&state=WA&zip=20500")
MsgBox % whr.ResponseText
User avatar
TheDewd
Posts: 1131
Joined: 19 Dec 2013, 11:16
Location: USA

Re: WinHttpRequest (An error occurred in the secure channel support)

22 Oct 2018, 14:35

I still receive an error. It is probably the security settings for this computer.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.

Return to “Ask For Help”

Who is online

Users browsing this forum: Scr1pter, Xtra and 49 guests