Sample code for 30+ languages & platforms
Lianja Requires Chilkat v11.0.0+

HTTP POST with Binary Data in Request Body

See more HTTP Examples

Do an HTTPS POST with a binary request body.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

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

loHttp = createobject("CkHttp")

loFac = createobject("CkFileAccess")

loReqBody = loFac.ReadEntireFile("qa_data/pdf/helloWorld.pdf")

loResp = createobject("CkHttpResponse")
llSuccess = loHttp.HttpBinary("POST","https://example.com/something",loReqBody,"application/pdf",loResp)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loFac
    release loResp
    return
endif

lnResponseStatusCode = loResp.StatusCode
? "Status code: " + str(lnResponseStatusCode)

//  For example, if the response is XML, JSON, HTML, etc.
? "response body:"
? loResp.BodyStr


release loHttp
release loFac
release loResp