Unicode C++
Unicode C++
SugarCRM Logout
See more SugarCRM Examples
Demonstrates how to logout of a session.Chilkat Unicode C++ Downloads
#include <CkRestW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
bool success = false;
CkRestW rest;
success = rest.Connect(L"your.site.domain",443,true,true);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
rest.AddHeader(L"Cache-Control",L"no-cache");
rest.AddHeader(L"OAuth-Token",L"<access_token>");
CkStringBuilderW sbReq;
CkStringBuilderW sbJson;
success = rest.FullRequestSb(L"POST",L"/rest/v10/oauth2/logout",sbReq,sbJson);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
if (rest.get_ResponseStatusCode() != 200) {
wprintf(L"Received error response code: %d\n",rest.get_ResponseStatusCode());
wprintf(L"Response body:\n");
wprintf(L"%s\n",sbJson.getAsString());
return;
}
CkJsonObjectW json;
json.LoadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
success = json.BoolOf(L"success");
// A sample JSON response body that is parsed by the above code:
// {
// "success": true
// }
wprintf(L"Example Completed.\n");
}