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
(Unicode C) HTTP POST with Binary Data in Request BodyDo an HTTPS POST with a binary request body.
#include <C_CkHttpW.h> #include <C_CkFileAccessW.h> #include <C_CkByteData.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkFileAccessW fac; HCkByteData reqBody; const wchar_t *responseStr; int responseStatusCode; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); fac = CkFileAccessW_Create(); reqBody = CkByteData_Create(); success = CkFileAccessW_ReadEntireFile(fac,L"qa_data/pdf/helloWorld.pdf",reqBody); responseStr = CkHttpW_postBinary(http,L"https://example.com/something",reqBody,L"application/pdf",FALSE,FALSE); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkFileAccessW_Dispose(fac); CkByteData_Dispose(reqBody); return; } responseStatusCode = CkHttpW_getLastStatus(http); wprintf(L"Status code: %d\n",responseStatusCode); // For example, if the response is XML, JSON, HTML, etc. wprintf(L"response body:\n"); wprintf(L"%s\n",responseStr); CkHttpW_Dispose(http); CkFileAccessW_Dispose(fac); CkByteData_Dispose(reqBody); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.