Unicode C++
Unicode C++
Send a Bodyless REST Request into a StringBuilder
See more REST Examples
Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.
Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.
Chilkat Unicode C++ Downloads
#include <CkRestW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
bool success = false;
CkRestW rest;
bool bTls = true;
bool bAutoReconnect = true;
success = rest.Connect(L"example.com",443,bTls,bAutoReconnect);
if (success == false) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
CkStringBuilderW sbResponse;
success = rest.FullRequestNoBodySb(L"GET",L"/api/items/123",sbResponse);
if (success == false) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
const wchar_t *responseText = sbResponse.getAsString();
if (sbResponse.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",sbResponse.lastErrorText());
return;
}
wprintf(L"%s\n",responseText);
}