C / Datadog API Collection / Get a browser test's latest results summaries
Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject queryParams;
HCkHttpResponse resp;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *check_time;
const char *probe_dc;
const char *Id;
const char *Name;
int Height;
int Width;
BOOL IsMobile;
const char *Duration;
int ErrorCount;
int StepCountCompleted;
int StepCountTotal;
const char *result_id;
int status;
int last_timestamp_fetched;
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();
queryParams = CkJsonObject_Create();
CkJsonObject_UpdateInt(queryParams,"from_ts",-62147425);
CkJsonObject_UpdateInt(queryParams,"to_ts",-62147425);
CkJsonObject_UpdateString(queryParams,"probe_dc","dolor cillum in");
CkJsonObject_UpdateString(queryParams,"probe_dc","proident");
CkHttp_SetRequestHeader(http,"Accept","application/json");
resp = CkHttp_QuickRequestParams(http,"GET","https://api.app.ddog-gov.com/api/v1/synthetics/tests/browser/:public_id/results",queryParams);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
return;
}
sbResponseBody = CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttpResponse_getStatusCode(resp);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttpResponse_header(resp));
printf("Failed.\n");
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
CkHttpResponse_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "last_timestamp_fetched": 65993172,
// "results": [
// {
// "check_time": -9878780.847290918,
// "probe_dc": "i",
// "result": {
// "device": {
// "id": "laptop_large",
// "name": "",
// "height": 0,
// "width": 0,
// "isMobile": true
// },
// "duration": 65442267.72030264,
// "errorCount": 64702081,
// "stepCountCompleted": -72535032,
// "stepCountTotal": 82995949
// },
// "result_id": "labore",
// "status": 2
// },
// {
// "check_time": -2600599.1306800246,
// "probe_dc": "ex et tempor",
// "result": {
// "device": {
// "id": "laptop_large",
// "name": "",
// "height": 0,
// "width": 0,
// "isMobile": false
// },
// "duration": 61853655.027596265,
// "errorCount": -10809730,
// "stepCountCompleted": 76168853,
// "stepCountTotal": 95663724
// },
// "result_id": "occaecat",
// "status": 1
// }
// ]
// }
// 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.
last_timestamp_fetched = CkJsonObject_IntOf(jResp,"last_timestamp_fetched");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"results");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
check_time = CkJsonObject_stringOf(jResp,"results[i].check_time");
probe_dc = CkJsonObject_stringOf(jResp,"results[i].probe_dc");
Id = CkJsonObject_stringOf(jResp,"results[i].result.device.id");
Name = CkJsonObject_stringOf(jResp,"results[i].result.device.name");
Height = CkJsonObject_IntOf(jResp,"results[i].result.device.height");
Width = CkJsonObject_IntOf(jResp,"results[i].result.device.width");
IsMobile = CkJsonObject_BoolOf(jResp,"results[i].result.device.isMobile");
Duration = CkJsonObject_stringOf(jResp,"results[i].result.duration");
ErrorCount = CkJsonObject_IntOf(jResp,"results[i].result.errorCount");
StepCountCompleted = CkJsonObject_IntOf(jResp,"results[i].result.stepCountCompleted");
StepCountTotal = CkJsonObject_IntOf(jResp,"results[i].result.stepCountTotal");
result_id = CkJsonObject_stringOf(jResp,"results[i].result_id");
status = CkJsonObject_IntOf(jResp,"results[i].status");
i = i + 1;
}
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -G -d "from_ts=-62147425"
-d "to_ts=-62147425"
-d "probe_dc=dolor%20cillum%20in"
-d "probe_dc=proident"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/synthetics/tests/browser/:public_id/results
Postman Collection Item JSON
{
"name": "Get a browser test's latest results summaries",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/synthetics/tests/browser/:public_id/results?from_ts=-62147425&to_ts=-62147425&probe_dc=dolor cillum in&probe_dc=proident",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"synthetics",
"tests",
"browser",
":public_id",
"results"
],
"query": [
{
"key": "from_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds from which to start querying results."
},
{
"key": "to_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds up to which to query results."
},
{
"key": "probe_dc",
"value": "dolor cillum in",
"description": "Locations for which to query results."
},
{
"key": "probe_dc",
"value": "proident",
"description": "Locations for which to query results."
}
],
"variable": [
{
"key": "public_id",
"value": "tempor Ut sed velit"
}
]
},
"description": "Get the last 150 test results summaries for a given Synthetic browser test."
},
"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/v1/synthetics/tests/browser/:public_id/results?from_ts=-62147425&to_ts=-62147425&probe_dc=proident",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"synthetics",
"tests",
"browser",
":public_id",
"results"
],
"query": [
{
"key": "from_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds from which to start querying results."
},
{
"key": "to_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds up to which to query results."
},
{
"key": "probe_dc",
"value": "proident",
"description": "Locations for which to query results."
}
],
"variable": [
{
"key": "public_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"last_timestamp_fetched\": 65993172,\n \"results\": [\n {\n \"check_time\": -9878780.847290918,\n \"probe_dc\": \"i\",\n \"result\": {\n \"device\": {\n \"id\": \"laptop_large\",\n \"name\": \"\",\n \"height\": 0,\n \"width\": 0,\n \"isMobile\": true\n },\n \"duration\": 65442267.72030264,\n \"errorCount\": 64702081,\n \"stepCountCompleted\": -72535032,\n \"stepCountTotal\": 82995949\n },\n \"result_id\": \"labore\",\n \"status\": 2\n },\n {\n \"check_time\": -2600599.1306800246,\n \"probe_dc\": \"ex et tempor\",\n \"result\": {\n \"device\": {\n \"id\": \"laptop_large\",\n \"name\": \"\",\n \"height\": 0,\n \"width\": 0,\n \"isMobile\": false\n },\n \"duration\": 61853655.027596265,\n \"errorCount\": -10809730,\n \"stepCountCompleted\": 76168853,\n \"stepCountTotal\": 95663724\n },\n \"result_id\": \"occaecat\",\n \"status\": 1\n }\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/v1/synthetics/tests/browser/:public_id/results?from_ts=-62147425&to_ts=-62147425&probe_dc=proident",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"synthetics",
"tests",
"browser",
":public_id",
"results"
],
"query": [
{
"key": "from_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds from which to start querying results."
},
{
"key": "to_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds up to which to query results."
},
{
"key": "probe_dc",
"value": "proident",
"description": "Locations for which to query results."
}
],
"variable": [
{
"key": "public_id"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "- Synthetic Monitoring is not activated for the user\n- Test is not owned by the user",
"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/v1/synthetics/tests/browser/:public_id/results?from_ts=-62147425&to_ts=-62147425&probe_dc=proident",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"synthetics",
"tests",
"browser",
":public_id",
"results"
],
"query": [
{
"key": "from_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds from which to start querying results."
},
{
"key": "to_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds up to which to query results."
},
{
"key": "probe_dc",
"value": "proident",
"description": "Locations for which to query results."
}
],
"variable": [
{
"key": "public_id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\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/v1/synthetics/tests/browser/:public_id/results?from_ts=-62147425&to_ts=-62147425&probe_dc=proident",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"synthetics",
"tests",
"browser",
":public_id",
"results"
],
"query": [
{
"key": "from_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds from which to start querying results."
},
{
"key": "to_ts",
"value": "-62147425",
"description": "Timestamp in milliseconds up to which to query results."
},
{
"key": "probe_dc",
"value": "proident",
"description": "Locations for which to query results."
}
],
"variable": [
{
"key": "public_id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
}
]
}