(AutoIt) qa.factura1.com.co Obtain Auth Token
Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; Build the following JSON
; {
; "password": "MY_PASSWORD",
; "username": "MY_USERNAME"
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.EmitCompact = False
$oJson.UpdateString("password","MY_PASSWORD")
$oJson.UpdateString("username","MY_USERNAME")
Local $oResp = $oHttp.PostJson3("https://qa.factura1.com.co/v2/auth","application/json",$oJson)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJsonResp = ObjCreate("Chilkat.JsonObject")
$oJsonResp.EmitCompact = False
$oJsonResp.Load($oResp.BodyStr)
ConsoleWrite($oJsonResp.Emit() & @CRLF)
ConsoleWrite("Access token: " & $oJsonResp.StringOf("token") & @CRLF)
|