Unicode C
Unicode C
Bluzone Get Project Details
See more Bluzone Examples
Get a project by its idChilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
int projectId;
const wchar_t *name;
const wchar_t *description;
const wchar_t *status;
const wchar_t *ownerUsername;
const wchar_t *ownerEmailAddress;
const wchar_t *defaultUuidValue;
BOOL enableLocusMaps;
const wchar_t *mapProviderType;
BOOL enableAdvancedPackets;
const wchar_t *enabledPacketTypes;
BOOL enableDataUnload;
BOOL enableScanConsumer;
BOOL enablePolicyConsumer;
BOOL enableLocationConsumer;
BOOL enableEmail;
const wchar_t *firmwareUpdateStrategy;
int deviceJobConcurrency;
const wchar_t *mapProviderApiKey;
const wchar_t *wakeupUuid;
const wchar_t *reportTimezone;
const wchar_t *language;
const wchar_t *blufiHostnameNaming;
int dateCreated;
int dateUpdated;
BOOL enableStreamProducer;
BOOL enableMetricStorage;
int i;
int count_i;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Implements the following CURL command:
// curl -X GET \
// https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/ \
// -H 'bzid: YOUR_API_KEY_HERE'
CkHttpW_SetRequestHeader(http,L"bzid",L"YOUR_API_KEY_HERE");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// Sample JSON response:
// {
// "projectId": 36845,
// "name": "My Project",
// "description": "Default Project for admin@chilkatsoft.com, created on Thu Jun 06 17:18:11 GMT 2019.",
// "status": null,
// "owner": {
// "username": "admin@chilkatsoft.com",
// "emailAddress": null
// },
// "defaultUuidValue": "1b4b243c-59aa-405f-90b5-0c434cac1345",
// "enableLocusMaps": false,
// "mapProviderType": "GOOGLE",
// "enableAdvancedPackets": false,
// "enabledPacketTypes": "sBv2",
// "enableDataUnload": false,
// "enableScanConsumer": false,
// "enablePolicyConsumer": false,
// "enableLocationConsumer": false,
// "enableEmail": true,
// "firmwareUpdateStrategy": "MANUAL",
// "deviceJobConcurrency": -1,
// "mapProviderApiKey": null,
// "wakeupUuid": null,
// "reportEmailList": [
// ],
// "reportTimezone": "Etc/GMT",
// "language": "en",
// "blufiHostnameNaming": "DEFAULT",
// "dateCreated": 1559841491000,
// "dateUpdated": 1559841491000,
// "enableStreamProducer": true,
// "enableMetricStorage": true
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
projectId = CkJsonObjectW_IntOf(jResp,L"projectId");
name = CkJsonObjectW_stringOf(jResp,L"name");
description = CkJsonObjectW_stringOf(jResp,L"description");
status = CkJsonObjectW_stringOf(jResp,L"status");
ownerUsername = CkJsonObjectW_stringOf(jResp,L"owner.username");
ownerEmailAddress = CkJsonObjectW_stringOf(jResp,L"owner.emailAddress");
defaultUuidValue = CkJsonObjectW_stringOf(jResp,L"defaultUuidValue");
enableLocusMaps = CkJsonObjectW_BoolOf(jResp,L"enableLocusMaps");
mapProviderType = CkJsonObjectW_stringOf(jResp,L"mapProviderType");
enableAdvancedPackets = CkJsonObjectW_BoolOf(jResp,L"enableAdvancedPackets");
enabledPacketTypes = CkJsonObjectW_stringOf(jResp,L"enabledPacketTypes");
enableDataUnload = CkJsonObjectW_BoolOf(jResp,L"enableDataUnload");
enableScanConsumer = CkJsonObjectW_BoolOf(jResp,L"enableScanConsumer");
enablePolicyConsumer = CkJsonObjectW_BoolOf(jResp,L"enablePolicyConsumer");
enableLocationConsumer = CkJsonObjectW_BoolOf(jResp,L"enableLocationConsumer");
enableEmail = CkJsonObjectW_BoolOf(jResp,L"enableEmail");
firmwareUpdateStrategy = CkJsonObjectW_stringOf(jResp,L"firmwareUpdateStrategy");
deviceJobConcurrency = CkJsonObjectW_IntOf(jResp,L"deviceJobConcurrency");
mapProviderApiKey = CkJsonObjectW_stringOf(jResp,L"mapProviderApiKey");
wakeupUuid = CkJsonObjectW_stringOf(jResp,L"wakeupUuid");
reportTimezone = CkJsonObjectW_stringOf(jResp,L"reportTimezone");
language = CkJsonObjectW_stringOf(jResp,L"language");
blufiHostnameNaming = CkJsonObjectW_stringOf(jResp,L"blufiHostnameNaming");
dateCreated = CkJsonObjectW_IntOf(jResp,L"dateCreated");
dateUpdated = CkJsonObjectW_IntOf(jResp,L"dateUpdated");
enableStreamProducer = CkJsonObjectW_BoolOf(jResp,L"enableStreamProducer");
enableMetricStorage = CkJsonObjectW_BoolOf(jResp,L"enableMetricStorage");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"reportEmailList");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
i = i + 1;
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}