Back to Collection Items
#include <CkHttp.h>
#include <CkJsonObject.h>
#include <CkHttpResponse.h>
#include <CkStringBuilder.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
bool success;
CkJsonObject queryParams;
queryParams.UpdateString("schema_version","v1");
http.SetRequestHeader("Accept","application/json");
CkHttpResponse *resp = http.QuickRequestParams("GET","https://api.app.ddog-gov.com/api/v2/services/definitions/:service_name",queryParams);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
CkStringBuilder sbResponseBody;
resp->GetBodySb(sbResponseBody);
CkJsonObject jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
std::cout << "Response Body:" << "\r\n";
std::cout << jResp.emit() << "\r\n";
int respStatusCode = resp->get_StatusCode();
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
if (respStatusCode >= 400) {
std::cout << "Response Header:" << "\r\n";
std::cout << resp->header() << "\r\n";
std::cout << "Failed." << "\r\n";
delete resp;
return;
}
delete resp;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "attributes": {
// "meta": {
// "github-html-url": "<string>",
// "ingested-schema-version": "<string>",
// "ingestion-source": "<string>",
// "last-modified-time": "<string>",
// "origin": "<string>",
// "origin-detail": "<string>",
// "warnings": [
// {
// "instance-location": "<string>",
// "keyword-location": "<string>",
// "message": "<string>"
// },
// {
// "instance-location": "<string>",
// "keyword-location": "<string>",
// "message": "<string>"
// }
// ]
// },
// "schema": {
// "schema-version": "v1",
// "info": {
// "dd-service": "<string>",
// "description": "<string>",
// "display-name": "<string>",
// "service-tier": "<string>"
// },
// "contact": {
// "email": "<email>",
// "slack": "<string>"
// },
// "extensions": {
// "iruree76": {},
// "aliqua_0": {},
// "ad_3": {}
// },
// "external-resources": [
// {
// "name": "<string>",
// "type": "code",
// "url": "<string>"
// },
// {
// "name": "<string>",
// "type": "repo",
// "url": "<string>"
// }
// ],
// "integrations": {
// "pagerduty": "<string>"
// },
// "org": {
// "application": "<string>",
// "team": "<string>"
// },
// "tags": [
// "<string>",
// "<string>"
// ]
// }
// },
// "id": "<string>",
// "type": "<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.
const char *instance_location = 0;
const char *keyword_location = 0;
const char *message = 0;
const char *name = 0;
const char *v_type = 0;
const char *url = 0;
const char *strVal = 0;
const char *Github_html_url = jResp.stringOf("data.attributes.meta.github-html-url");
const char *Ingested_schema_version = jResp.stringOf("data.attributes.meta.ingested-schema-version");
const char *Ingestion_source = jResp.stringOf("data.attributes.meta.ingestion-source");
const char *Last_modified_time = jResp.stringOf("data.attributes.meta.last-modified-time");
const char *Origin = jResp.stringOf("data.attributes.meta.origin");
const char *Origin_detail = jResp.stringOf("data.attributes.meta.origin-detail");
const char *Schema_version = jResp.stringOf("data.attributes.schema.schema-version");
const char *Dd_service = jResp.stringOf("data.attributes.schema.info.dd-service");
const char *Description = jResp.stringOf("data.attributes.schema.info.description");
const char *Display_name = jResp.stringOf("data.attributes.schema.info.display-name");
const char *Service_tier = jResp.stringOf("data.attributes.schema.info.service-tier");
const char *v_Email = jResp.stringOf("data.attributes.schema.contact.email");
const char *Slack = jResp.stringOf("data.attributes.schema.contact.slack");
const char *Pagerduty = jResp.stringOf("data.attributes.schema.integrations.pagerduty");
const char *Application = jResp.stringOf("data.attributes.schema.org.application");
const char *Team = jResp.stringOf("data.attributes.schema.org.team");
const char *Id = jResp.stringOf("data.id");
const char *v_Type = jResp.stringOf("data.type");
int i = 0;
int count_i = jResp.SizeOfArray("data.attributes.meta.warnings");
while (i < count_i) {
jResp.put_I(i);
instance_location = jResp.stringOf("data.attributes.meta.warnings[i].instance-location");
keyword_location = jResp.stringOf("data.attributes.meta.warnings[i].keyword-location");
message = jResp.stringOf("data.attributes.meta.warnings[i].message");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("data.attributes.schema.external-resources");
while (i < count_i) {
jResp.put_I(i);
name = jResp.stringOf("data.attributes.schema.external-resources[i].name");
v_type = jResp.stringOf("data.attributes.schema.external-resources[i].type");
url = jResp.stringOf("data.attributes.schema.external-resources[i].url");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("data.attributes.schema.tags");
while (i < count_i) {
jResp.put_I(i);
strVal = jResp.stringOf("data.attributes.schema.tags[i]");
i = i + 1;
}
}
Curl Command
curl -G -d "schema_version=v1"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/services/definitions/:service_name
Postman Collection Item JSON
{
"name": "Get a single service definition",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name",
"value": "<string>"
}
]
},
"description": "Get a single service definition from the Datadog Service Catalog."
},
"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/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"attributes\": {\n \"meta\": {\n \"github-html-url\": \"<string>\",\n \"ingested-schema-version\": \"<string>\",\n \"ingestion-source\": \"<string>\",\n \"last-modified-time\": \"<string>\",\n \"origin\": \"<string>\",\n \"origin-detail\": \"<string>\",\n \"warnings\": [\n {\n \"instance-location\": \"<string>\",\n \"keyword-location\": \"<string>\",\n \"message\": \"<string>\"\n },\n {\n \"instance-location\": \"<string>\",\n \"keyword-location\": \"<string>\",\n \"message\": \"<string>\"\n }\n ]\n },\n \"schema\": {\n \"schema-version\": \"v1\",\n \"info\": {\n \"dd-service\": \"<string>\",\n \"description\": \"<string>\",\n \"display-name\": \"<string>\",\n \"service-tier\": \"<string>\"\n },\n \"contact\": {\n \"email\": \"<email>\",\n \"slack\": \"<string>\"\n },\n \"extensions\": {\n \"iruree76\": {},\n \"aliqua_0\": {},\n \"ad_3\": {}\n },\n \"external-resources\": [\n {\n \"name\": \"<string>\",\n \"type\": \"code\",\n \"url\": \"<string>\"\n },\n {\n \"name\": \"<string>\",\n \"type\": \"repo\",\n \"url\": \"<string>\"\n }\n ],\n \"integrations\": {\n \"pagerduty\": \"<string>\"\n },\n \"org\": {\n \"application\": \"<string>\",\n \"team\": \"<string>\"\n },\n \"tags\": [\n \"<string>\",\n \"<string>\"\n ]\n }\n },\n \"id\": \"<string>\",\n \"type\": \"<string>\"\n }\n}"
},
{
"name": "Bad Request",
"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/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
},
{
"name": "Forbidden",
"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/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
},
{
"name": "Not Found",
"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/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name"
}
]
}
},
"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": "Conflict",
"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/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name"
}
]
}
},
"status": "Conflict",
"code": 409,
"_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/services/definitions/:service_name?schema_version=v1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"services",
"definitions",
":service_name"
],
"query": [
{
"key": "schema_version",
"value": "v1",
"description": "The schema version desired in the response."
}
],
"variable": [
{
"key": "service_name"
}
]
}
},
"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}"
}
]
}