Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) HTTP POST with Binary Data in Request BodyDo an HTTPS POST with a binary request body.
#include <C_CkHttp.h> #include <C_CkFileAccess.h> #include <C_CkByteData.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkFileAccess fac; HCkByteData reqBody; const char *responseStr; int responseStatusCode; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttp_Create(); fac = CkFileAccess_Create(); reqBody = CkByteData_Create(); success = CkFileAccess_ReadEntireFile(fac,"qa_data/pdf/helloWorld.pdf",reqBody); responseStr = CkHttp_postBinary(http,"https://example.com/something",reqBody,"application/pdf",FALSE,FALSE); if (CkHttp_getLastMethodSuccess(http) == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkFileAccess_Dispose(fac); CkByteData_Dispose(reqBody); return; } responseStatusCode = CkHttp_getLastStatus(http); printf("Status code: %d\n",responseStatusCode); // For example, if the response is XML, JSON, HTML, etc. printf("response body:\n"); printf("%s\n",responseStr); CkHttp_Dispose(http); CkFileAccess_Dispose(fac); CkByteData_Dispose(reqBody); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.