AutoIT‎ > ‎

AutoIT http POST Request

posted Feb 25, 2014, 1:33 PM by Chris G   [ updated Oct 13, 2016, 6:11 PM ]
AutoIT Code Sample - a quick way to make an http (or https) POST request to a web service and process the returned value:

;===============================================================================
; Description:		AutoIT http POST Request
; Author(s):		Videre Research, LLC - http://videreresearch.com
;===============================================================================

$sPD = 'parm1=aaa&parm2=bbb'
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "https://my.full.url/service", False)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sPD)
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status

ConsoleWrite($oStatusCode & @CRLF)
;ConsoleWrite($oReceived)
If $oStatusCode = 200 Then
	;Process the response $oReceived
Else
	MsgBox(16, "Error " & $oStatusCode, $oReceived, 7)
EndIf
Comments