DataFlex Requires Chilkat v11.0.0+
DataFlex
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Handle hoFac
Variant hoReqBody
Variant vResp
Handle hoResp
Integer iResponseStatusCode
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Get Create (RefClass(cComCkFileAccess)) To hoFac
If (Not(IsComObjectCreated(hoFac))) Begin
Send CreateComObject of hoFac
End
Get ComReadEntireFile Of hoFac "qa_data/pdf/helloWorld.pdf" To hoReqBody
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoResp to vResp
Get ComHttpBinary Of hoHttp "POST" "https://example.com/something" vReqBody "application/pdf" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iResponseStatusCode
Showln "Status code: " iResponseStatusCode
// For example, if the response is XML, JSON, HTML, etc.
Showln "response body:"
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
End_Procedure