Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) HTTP POST with Binary Data in Request BodyDo an HTTPS POST with a binary request body.
#include <CkHttp.h> #include <CkFileAccess.h> #include <CkByteData.h> void ChilkatSample(void) { CkString strOut; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; bool success; CkFileAccess fac; CkByteData reqBody; success = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf",reqBody); const char *responseStr = http.postBinary("https://example.com/something",reqBody,"application/pdf",false,false); if (http.get_LastMethodSuccess() == false) { strOut.append(http.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } int responseStatusCode = http.get_LastStatus(); strOut.append("Status code: "); strOut.appendInt(responseStatusCode); strOut.append("\r\n"); // For example, if the response is XML, JSON, HTML, etc. strOut.append("response body:"); strOut.append("\r\n"); strOut.append(responseStr); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.