DataFlex Requires Chilkat v11.0.0+
DataFlex
Example: Http.HttpBinary method
Demonstrates theHttpBinary method.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
String sLocalFilePath
Handle hoBd
Variant hoZipBytes
String sUrl
Variant vResp
Handle hoResp
Handle hoHttp
String sTemp1
Integer iTemp1
Move False To iSuccess
Move "C:/example/zips/data.zip" To sLocalFilePath
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Get ComLoadFile Of hoBd sLocalFilePath To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoBd To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComGetData Of hoBd To hoZipBytes
Move "https://example.com/api/v1/sites/123/deploys" To sUrl
// Send a POST with a binary HTTP request body.
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Get pvComObject of hoResp to vResp
Get ComHttpBinary Of hoHttp "POST" sUrl vZipBytes "application/zip" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln "Response Status Code: " iTemp1
Showln "Response body:"
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
End_Procedure