Sample code for 30+ languages & platforms
Lianja

POST application/json HTTPS Request

See more HTTP Examples

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.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

// 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 = createobject("CkHttpResponse")
llSuccess = loHttp.HttpStr("POST",lcUrl,lcJsonRequestBody,"utf-8","application/json",loResp)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loResp
    return
endif

? "Response status code = " + str(loResp.StatusCode)
lcJsonResponseStr = loResp.BodyStr

? lcJsonResponseStr


release loHttp
release loResp