Unicode C++
Unicode C++
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkFileAccessW.h>
#include <CkByteData.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
CkFileAccessW fac;
CkByteData reqBody;
success = fac.ReadEntireFile(L"qa_data/pdf/helloWorld.pdf",reqBody);
CkHttpResponseW resp;
success = http.HttpBinary(L"POST",L"https://example.com/something",reqBody,L"application/pdf",resp);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
int responseStatusCode = resp.get_StatusCode();
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",resp.bodyStr());
}