(Lianja) 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.
loHttp = createobject("CkHttp")
// Build the following JSON
// {
// "password": "MY_PASSWORD",
// "username": "MY_USERNAME"
// }
loJson = createobject("CkJsonObject")
loJson.EmitCompact = .F.
loJson.UpdateString("password","MY_PASSWORD")
loJson.UpdateString("username","MY_USERNAME")
loResp = loHttp.PostJson3("https://qa.factura1.com.co/v2/auth","application/json",loJson)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loJson
return
endif
loJsonResp = createobject("CkJsonObject")
loJsonResp.EmitCompact = .F.
loJsonResp.Load(loResp.BodyStr)
release loResp
? loJsonResp.Emit()
? "Access token: " + loJsonResp.StringOf("token")
release loHttp
release loJson
release loJsonResp
|