Back to Collection Items
var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
resp: HCkHttpResponse;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
strVal: PWideChar;
id: PWideChar;
timeframe: PWideChar;
message: PWideChar;
i: Integer;
count_i: Integer;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "id1": [
// "7d",
// "30d"
// ],
// "id2": [
// "7d",
// "30d"
// ]
// }
json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'id1[0]','7d');
CkJsonObject_UpdateString(json,'id1[1]','30d');
CkJsonObject_UpdateString(json,'id2[0]','7d');
CkJsonObject_UpdateString(json,'id2[1]','30d');
CkHttp_SetRequestHeader(http,'Content-Type','application/json');
CkHttp_SetRequestHeader(http,'Accept','application/json');
resp := CkHttp_PostJson3(http,'https://api.app.ddog-gov.com/api/v1/slo/bulk_delete','application/json',json);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
sbResponseBody := CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttpResponse__header(resp));
Memo1.Lines.Add('Failed.');
CkHttpResponse_Dispose(resp);
Exit;
end;
CkHttpResponse_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "deleted": [
// "aliqua aute sit in",
// "mollit sit magna"
// ],
// "updated": [
// "nisi eiusmod",
// "elit adipisicing"
// ]
// },
// "errors": [
// {
// "id": "",
// "timeframe": "30d",
// "message": ""
// },
// {
// "id": "",
// "timeframe": "30d",
// "message": ""
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'data.deleted');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'data.deleted[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'data.updated');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
strVal := CkJsonObject__stringOf(jResp,'data.updated[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'errors');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
id := CkJsonObject__stringOf(jResp,'errors[i].id');
timeframe := CkJsonObject__stringOf(jResp,'errors[i].timeframe');
message := CkJsonObject__stringOf(jResp,'errors[i].message');
i := i + 1;
end;
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"id1": [
"7d",
"30d"
],
"id2": [
"7d",
"30d"
]
}'
https://api.app.ddog-gov.com/api/v1/slo/bulk_delete
Postman Collection Item JSON
{
"name": "Bulk Delete SLO Timeframes",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id1\": [\n \"7d\",\n \"30d\"\n ],\n \"id2\": [\n \"7d\",\n \"30d\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/bulk_delete",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"bulk_delete"
]
},
"description": "Delete (or partially delete) multiple service level objective objects.\n\nThis endpoint facilitates deletion of one or more thresholds for one or more\nservice level objective objects. If all thresholds are deleted, the service level\nobjective object is deleted as well."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id1\": [\n \"7d\",\n \"30d\"\n ],\n \"id2\": [\n \"7d\",\n \"30d\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/bulk_delete",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"bulk_delete"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"deleted\": [\n \"aliqua aute sit in\",\n \"mollit sit magna\"\n ],\n \"updated\": [\n \"nisi eiusmod\",\n \"elit adipisicing\"\n ]\n },\n \"errors\": [\n {\n \"id\": \"\",\n \"timeframe\": \"30d\",\n \"message\": \"\"\n },\n {\n \"id\": \"\",\n \"timeframe\": \"30d\",\n \"message\": \"\"\n }\n ]\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id1\": [\n \"7d\",\n \"30d\"\n ],\n \"id2\": [\n \"7d\",\n \"30d\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/bulk_delete",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"bulk_delete"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Forbidden",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id1\": [\n \"7d\",\n \"30d\"\n ],\n \"id2\": [\n \"7d\",\n \"30d\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/bulk_delete",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"bulk_delete"
]
}
},
"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": "Too many requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id1\": [\n \"7d\",\n \"30d\"\n ],\n \"id2\": [\n \"7d\",\n \"30d\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/bulk_delete",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"bulk_delete"
]
}
},
"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}"
}
]
}