Back to Collection Items
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
http.SetRequestHeader(L"Authorization",L"{{apiKey}}");
http.SetRequestHeader(L"Accept",L"application/json");
CkStringBuilderW sbResponseBody;
success = http.QuickGetSb(L"https://api.easybill.de/rest/v1/logins/:id",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)
// {
// "id": "<long>",
// "first_name": "<string>",
// "last_name": "<string>",
// "display_name": "<string>",
// "phone": "<string>",
// "email": "<string>",
// "email_signature": "<string>",
// "login_type": "ASSISTANT",
// "locale": "<string>",
// "time_zone": "<string>",
// "security": {
// "two_factor_enabled": false,
// "recovery_codes_enabled": false,
// "notify_on_new_login_enabled": true
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
const wchar_t *id = jResp.stringOf(L"id");
const wchar_t *first_name = jResp.stringOf(L"first_name");
const wchar_t *last_name = jResp.stringOf(L"last_name");
const wchar_t *display_name = jResp.stringOf(L"display_name");
const wchar_t *phone = jResp.stringOf(L"phone");
const wchar_t *email = jResp.stringOf(L"email");
const wchar_t *email_signature = jResp.stringOf(L"email_signature");
const wchar_t *login_type = jResp.stringOf(L"login_type");
const wchar_t *locale = jResp.stringOf(L"locale");
const wchar_t *time_zone = jResp.stringOf(L"time_zone");
bool Two_factor_enabled = jResp.BoolOf(L"security.two_factor_enabled");
bool Recovery_codes_enabled = jResp.BoolOf(L"security.recovery_codes_enabled");
bool Notify_on_new_login_enabled = jResp.BoolOf(L"security.notify_on_new_login_enabled");
}
Curl Command
curl -X GET
-H "Authorization: {{apiKey}}"
-H "Accept: application/json"
https://api.easybill.de/rest/v1/logins/:id
Postman Collection Item JSON
{
"name": "/logins/:id",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/logins/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"logins",
":id"
],
"variable": [
{
"key": "id",
"value": "<long>",
"description": "(Required) ID of the login that needs to be fetched"
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/logins/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"logins",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"id\": \"<long>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"display_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"<string>\",\n \"email_signature\": \"<string>\",\n \"login_type\": \"ASSISTANT\",\n \"locale\": \"<string>\",\n \"time_zone\": \"<string>\",\n \"security\": {\n \"two_factor_enabled\": false,\n \"recovery_codes_enabled\": false,\n \"notify_on_new_login_enabled\": true\n }\n}"
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/logins/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"logins",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}