(Visual FoxPro) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body.
LOCAL loHttp
LOCAL lnSuccess
LOCAL loFac
LOCAL loReqBody
LOCAL lcResponseStr
LOCAL lnResponseStatusCode
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.FileAccess')
loFac = CreateObject('Chilkat.FileAccess')
loReqBody = loFac.ReadEntireFile("qa_data/pdf/helloWorld.pdf")
lcResponseStr = loHttp.PostBinary("https://example.com/something",loReqBody,"application/pdf",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loFac
CANCEL
ENDIF
lnResponseStatusCode = loHttp.LastStatus
? "Status code: " + STR(lnResponseStatusCode)
* For example, if the response is XML, JSON, HTML, etc.
? "response body:"
? lcResponseStr
RELEASE loHttp
RELEASE loFac
|