(Lianja) POST application/json HTTPS Request
Demonstrates how to send an HTTPS POST where the request body and response body both have the application/json Content-Type. Also demonstrates how to add a few custom headers to the request.
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code
loHttp = createobject("CkHttp")
// Add a few custom headers.
loHttp.SetRequestHeader("Client-ID","my_client_id")
loHttp.SetRequestHeader("Client-Token","my_client_token")
loHttp.Accept = "application/json"
lcUrl = "https://api.fiscallog.eu/sign/v1"
lcJsonRequestBody = "{ .... }"
loResp = loHttp.PostJson2(lcUrl,"application/json",lcJsonRequestBody)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
return
endif
? "Response status code = " + str(loResp.StatusCode)
lcJsonResponseStr = loResp.BodyStr
? lcJsonResponseStr
release loResp
release loHttp
|