Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *strVal;
const char *id;
const char *v_type;
const char *Handle;
const char *Name;
const char *Avatar;
const char *Banner;
const char *Created_at;
const char *Description;
const char *Link_count;
const char *Modified_at;
const char *Summary;
const char *User_count;
const char *Id;
const char *v_Type;
const char *Related;
const char *DataId;
const char *DataType;
const char *LinksRelated;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
CkHttp_SetRequestHeader(http,"Accept","application/json");
sbResponseBody = CkStringBuilder_Create();
success = CkHttp_QuickGetSb(http,"https://api.app.ddog-gov.com/api/v2/team/:team_id",sbResponseBody);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttp_getLastStatus(http);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttp_lastHeader(http));
printf("Failed.\n");
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "attributes": {
// "handle": "<string>",
// "name": "<string>",
// "avatar": "<string>",
// "banner": "<long>",
// "created_at": "<dateTime>",
// "description": "<string>",
// "hidden_modules": [
// "<string>",
// "<string>"
// ],
// "link_count": "<integer>",
// "modified_at": "<dateTime>",
// "summary": "<string>",
// "user_count": "<integer>",
// "visible_modules": [
// "<string>",
// "<string>"
// ]
// },
// "id": "<string>",
// "type": "team",
// "relationships": {
// "team_links": {
// "data": [
// {
// "id": "<string>",
// "type": "team_links"
// },
// {
// "id": "<string>",
// "type": "team_links"
// }
// ],
// "links": {
// "related": "<string>"
// }
// },
// "user_team_permissions": {
// "data": {
// "id": "<string>",
// "type": "user_team_permissions"
// },
// "links": {
// "related": "<string>"
// }
// }
// }
// }
// }
// 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.
Handle = CkJsonObject_stringOf(jResp,"data.attributes.handle");
Name = CkJsonObject_stringOf(jResp,"data.attributes.name");
Avatar = CkJsonObject_stringOf(jResp,"data.attributes.avatar");
Banner = CkJsonObject_stringOf(jResp,"data.attributes.banner");
Created_at = CkJsonObject_stringOf(jResp,"data.attributes.created_at");
Description = CkJsonObject_stringOf(jResp,"data.attributes.description");
Link_count = CkJsonObject_stringOf(jResp,"data.attributes.link_count");
Modified_at = CkJsonObject_stringOf(jResp,"data.attributes.modified_at");
Summary = CkJsonObject_stringOf(jResp,"data.attributes.summary");
User_count = CkJsonObject_stringOf(jResp,"data.attributes.user_count");
Id = CkJsonObject_stringOf(jResp,"data.id");
v_Type = CkJsonObject_stringOf(jResp,"data.type");
Related = CkJsonObject_stringOf(jResp,"data.relationships.team_links.links.related");
DataId = CkJsonObject_stringOf(jResp,"data.relationships.user_team_permissions.data.id");
DataType = CkJsonObject_stringOf(jResp,"data.relationships.user_team_permissions.data.type");
LinksRelated = CkJsonObject_stringOf(jResp,"data.relationships.user_team_permissions.links.related");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"data.attributes.hidden_modules");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
strVal = CkJsonObject_stringOf(jResp,"data.attributes.hidden_modules[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"data.attributes.visible_modules");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
strVal = CkJsonObject_stringOf(jResp,"data.attributes.visible_modules[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"data.relationships.team_links.data");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
id = CkJsonObject_stringOf(jResp,"data.relationships.team_links.data[i].id");
v_type = CkJsonObject_stringOf(jResp,"data.relationships.team_links.data[i].type");
i = i + 1;
}
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/team/:team_id
Postman Collection Item JSON
{
"name": "Get a team",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/team/:team_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"team",
":team_id"
],
"variable": [
{
"key": "team_id",
"value": "<string>"
}
]
},
"description": "Get a single team using the team's `id`."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/team/:team_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"team",
":team_id"
],
"variable": [
{
"key": "team_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"attributes\": {\n \"handle\": \"<string>\",\n \"name\": \"<string>\",\n \"avatar\": \"<string>\",\n \"banner\": \"<long>\",\n \"created_at\": \"<dateTime>\",\n \"description\": \"<string>\",\n \"hidden_modules\": [\n \"<string>\",\n \"<string>\"\n ],\n \"link_count\": \"<integer>\",\n \"modified_at\": \"<dateTime>\",\n \"summary\": \"<string>\",\n \"user_count\": \"<integer>\",\n \"visible_modules\": [\n \"<string>\",\n \"<string>\"\n ]\n },\n \"id\": \"<string>\",\n \"type\": \"team\",\n \"relationships\": {\n \"team_links\": {\n \"data\": [\n {\n \"id\": \"<string>\",\n \"type\": \"team_links\"\n },\n {\n \"id\": \"<string>\",\n \"type\": \"team_links\"\n }\n ],\n \"links\": {\n \"related\": \"<string>\"\n }\n },\n \"user_team_permissions\": {\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"user_team_permissions\"\n },\n \"links\": {\n \"related\": \"<string>\"\n }\n }\n }\n }\n}"
},
{
"name": "API error response.",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/team/:team_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"team",
":team_id"
],
"variable": [
{
"key": "team_id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
},
{
"name": "Too many requests",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/team/:team_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"team",
":team_id"
],
"variable": [
{
"key": "team_id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
}
]
}