Unicode C++
Unicode C++
SCIS Health Check
See more SCiS Schools Catalogue Examples
Demonstrates the SCIS (Schools Catalogue Information Service) health check API call.Chilkat Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.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;
// Implements the following CURL command:
// curl -i -X GET --url https://api.scisdata.com/checkStatus -H 'Authorization: Basic ****'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// This causes the "Authorization: Basic ****" to be added to each request.
http.put_Login(L"myLogin");
http.put_Password(L"myPassword");
http.put_BasicAuth(true);
CkStringBuilderW sbResponseBody;
success = http.QuickGetSb(L"https://api.scisdata.com/checkStatus",sbResponseBody);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
CkJsonObjectW jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",jResp.emit());
int respStatusCode = http.get_LastStatus();
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",http.lastHeader());
wprintf(L"Failed.\n");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
//
// {
// "subscriptionStatus": {
// "messages": [
// "Connection to SCIS API is successful",
// "User has a valid SCIS Data subscription"
// ]
// }
// }
}