Sample code for 30+ languages & platforms
Visual FoxPro

HTTP POST with Binary Data in Request Body

See more HTTP Examples

Do an HTTPS POST with a binary request body.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL loFac
LOCAL loReqBody
LOCAL loResp
LOCAL lnResponseStatusCode

lnSuccess = 0

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

loHttp = CreateObject('Chilkat.Http')

loFac = CreateObject('Chilkat.FileAccess')

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

loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpBinary("POST","https://example.com/something",loReqBody,"application/pdf",loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loFac
    RELEASE loResp
    CANCEL
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