Sample code for 30+ languages & platforms
AutoIt

TicketBAI -- Send HTTP POST

See more TicketBAI Examples

Demonstrates how to send a TicketBAI POST and get the response.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")

$bSuccess = $oHttp.SetSslClientCertPfx("your.pfx","pfx_password")
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

; Get the XML we wish to send in the body of the request.
$oSbXml = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oSbXml.LoadFile("qa_data/payload.xml","utf-8")
If ($bSuccess = False) Then
    ConsoleWrite("Failed to load XML that is to be the HTTP request body" & @CRLF)
    Exit
EndIf

; Build the following JSON

; { 
;     "con": "LROE", 
;     "apa": "1.1", 
;     "inte": { 
;         "nif": "número de identificación fiscal", 
;         "nrs": "nombre o Razón social", 
;         "ap1": "primer apellido", 
;         "ap2": "segundo apellido" 
;     }, 
;     "drs": { 
;     "mode": "140", 
;     "ejer": "ejercicio" 
;     } 
; }

; Use this online tool to generate code from sample JSON: 
; Generate Code to Create JSON

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("con","LROE")
$oJson.UpdateString("apa","1.1")
$oJson.UpdateString("inte.nif","número de identificación fiscal")
$oJson.UpdateString("inte.nrs","nombre o Razón social")
$oJson.UpdateString("inte.ap1","primer apellido")
$oJson.UpdateString("inte.ap2","segundo apellido")
$oJson.UpdateString("drs.mode","140")
$oJson.UpdateString("drs.ejer","ejercicio")

; Add required headers...
$oHttp.SetRequestHeader "eus-bizkaia-n3-version","1.0"
$oHttp.SetRequestHeader "eus-bizkaia-n3-content-type","application/xml"
$oHttp.SetRequestHeader "eus-bizkaia-n3-data",$oJson.Emit()

Local $sUrl = "https://pruesarrerak.bizkaia.eus/N3B4000M/aurkezpena"
$oResp = ObjCreate("Chilkat.HttpResponse")
$oHttp.UncommonOptions = "SendGzipped"
$bSuccess = $oHttp.HttpSb("POST",$sUrl,$oSbXml,"utf-8","application/octet-stream",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oHttp.ClearHeaders 

ConsoleWrite("response status code: " & $oResp.StatusCode & @CRLF)

; Examine the response (it is already decompressed)
ConsoleWrite("response body:" & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)