AutoIt
AutoIt
POST application/x-www-form-urlencoded using REST API
See more REST Examples
Demonstrates how to send a POST with query params (x-www-form-urlencoded) using the Chilkat REST object.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oRest = ObjCreate("Chilkat.Rest")
; This example will send to https://www.chilkatsoft.com/echoPost.asp
; Make the initial connection (without sending a request yet).
Local $bTls = True
Local $iPort = 443
Local $bAutoReconnect = True
$bSuccess = $oRest.Connect("www.chilkatsoft.com",$iPort,$bTls,$bAutoReconnect)
If ($bSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
; Provide query params.
$oRest.AddQueryParam("firstName","John")
$oRest.AddQueryParam("lastName","Doe")
$oRest.AddQueryParam("company","Bisco Bits Ltd.")
Local $sResponseStr = $oRest.FullRequestFormUrlEncoded("POST","/echoPost.asp")
If ($oRest.LastMethodSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
; When successful, the response status code will equal 200.
If ($oRest.ResponseStatusCode <> 200) Then
; Examine the request/response to see what happened.
ConsoleWrite("response status code = " & $oRest.ResponseStatusCode & @CRLF)
ConsoleWrite("response status text = " & $oRest.ResponseStatusText & @CRLF)
ConsoleWrite("response header: " & $oRest.ResponseHeader & @CRLF)
ConsoleWrite("response body (if any): " & $sResponseStr & @CRLF)
ConsoleWrite("---" & @CRLF)
ConsoleWrite("LastRequestStartLine: " & $oRest.LastRequestStartLine & @CRLF)
ConsoleWrite("LastRequestHeader: " & $oRest.LastRequestHeader & @CRLF)
Exit
EndIf
ConsoleWrite($sResponseStr & @CRLF)
ConsoleWrite("Success." & @CRLF)