Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "data": {
// "attributes": {
// "category": "Scheduled Maintenance",
// "description": "nisi ",
// "duration": 3600,
// "end": 1600000000,
// "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
// "start": 1600000000,
// "timezone": "UTC"
// },
// "type": "correction"
// }
// }
var json = new chilkat.JsonObject();
json.UpdateString("data.attributes.category","Scheduled Maintenance");
json.UpdateString("data.attributes.description","nisi ");
json.UpdateInt("data.attributes.duration",3600);
json.UpdateInt("data.attributes.end",1600000000);
json.UpdateString("data.attributes.rrule","FREQ=DAILY;INTERVAL=10;COUNT=5");
json.UpdateInt("data.attributes.start",1600000000);
json.UpdateString("data.attributes.timezone","UTC");
json.UpdateString("data.type","correction");
http.SetRequestHeader("Content-Type","application/json");
http.SetRequestHeader("Accept","application/json");
var sbRequestBody = new chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
// resp: HttpResponse
var resp = http.PTextSb("PATCH","https://api.app.ddog-gov.com/api/v1/slo/correction/:slo_correction_id",sbRequestBody,"utf-8","application/json",false,false);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
var sbResponseBody = new chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);
var jResp = new chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;
console.log("Response Body:");
console.log(jResp.Emit());
var respStatusCode = resp.StatusCode;
console.log("Response Status Code = " + respStatusCode);
if (respStatusCode >= 400) {
console.log("Response Header:");
console.log(resp.Header);
console.log("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "attributes": {
// "category": "Scheduled Maintenance",
// "created_at": 11806311,
// "creator": {
// "email": "dolor nisi",
// "handle": "la",
// "name": "in quis est cillum"
// },
// "description": "nostrud amet ea exercitation",
// "duration": 3600,
// "end": 30790629,
// "modified_at": 77538107,
// "modifier": {
// "email": "pariatur nisi minim reprehenderit",
// "handle": "irure commodo",
// "name": "veniam"
// },
// "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
// "slo_id": "incididunt qui velit sunt labore",
// "start": -34398281,
// "timezone": "eu id"
// },
// "id": "enim qui",
// "type": "correction"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var Category = jResp.StringOf("data.attributes.category");
var Created_at = jResp.IntOf("data.attributes.created_at");
var v_Email = jResp.StringOf("data.attributes.creator.email");
var Handle = jResp.StringOf("data.attributes.creator.handle");
var Name = jResp.StringOf("data.attributes.creator.name");
var Description = jResp.StringOf("data.attributes.description");
var Duration = jResp.IntOf("data.attributes.duration");
var v_End = jResp.IntOf("data.attributes.end");
var Modified_at = jResp.IntOf("data.attributes.modified_at");
var ModifierEmail = jResp.StringOf("data.attributes.modifier.email");
var ModifierHandle = jResp.StringOf("data.attributes.modifier.handle");
var ModifierName = jResp.StringOf("data.attributes.modifier.name");
var Rrule = jResp.StringOf("data.attributes.rrule");
var Slo_id = jResp.StringOf("data.attributes.slo_id");
var Start = jResp.IntOf("data.attributes.start");
var Timezone = jResp.StringOf("data.attributes.timezone");
var Id = jResp.StringOf("data.id");
var v_Type = jResp.StringOf("data.type");
}
chilkatExample();
Curl Command
curl -X PATCH
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"data": {
"attributes": {
"category": "Scheduled Maintenance",
"description": "nisi ",
"duration": 3600,
"end": 1600000000,
"rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
"start": 1600000000,
"timezone": "UTC"
},
"type": "correction"
}
}'
https://api.app.ddog-gov.com/api/v1/slo/correction/:slo_correction_id
Postman Collection Item JSON
{
"name": "Update an SLO correction",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"description\": \"nisi \",\n \"duration\": 3600,\n \"end\": 1600000000,\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"start\": 1600000000,\n \"timezone\": \"UTC\"\n },\n \"type\": \"correction\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"correction",
":slo_correction_id"
],
"variable": [
{
"key": "slo_correction_id",
"value": "tempor Ut sed velit"
}
]
},
"description": "Update the specified SLO correction object."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "PATCH",
"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 \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"description\": \"nisi \",\n \"duration\": 3600,\n \"end\": 1600000000,\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"start\": 1600000000,\n \"timezone\": \"UTC\"\n },\n \"type\": \"correction\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"correction",
":slo_correction_id"
],
"variable": [
{
"key": "slo_correction_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"created_at\": 11806311,\n \"creator\": {\n \"email\": \"dolor nisi\",\n \"handle\": \"la\",\n \"name\": \"in quis est cillum\"\n },\n \"description\": \"nostrud amet ea exercitation\",\n \"duration\": 3600,\n \"end\": 30790629,\n \"modified_at\": 77538107,\n \"modifier\": {\n \"email\": \"pariatur nisi minim reprehenderit\",\n \"handle\": \"irure commodo\",\n \"name\": \"veniam\"\n },\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"slo_id\": \"incididunt qui velit sunt labore\",\n \"start\": -34398281,\n \"timezone\": \"eu id\"\n },\n \"id\": \"enim qui\",\n \"type\": \"correction\"\n }\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "PATCH",
"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 \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"description\": \"nisi \",\n \"duration\": 3600,\n \"end\": 1600000000,\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"start\": 1600000000,\n \"timezone\": \"UTC\"\n },\n \"type\": \"correction\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"correction",
":slo_correction_id"
],
"variable": [
{
"key": "slo_correction_id"
}
]
}
},
"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": "PATCH",
"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 \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"description\": \"nisi \",\n \"duration\": 3600,\n \"end\": 1600000000,\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"start\": 1600000000,\n \"timezone\": \"UTC\"\n },\n \"type\": \"correction\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"correction",
":slo_correction_id"
],
"variable": [
{
"key": "slo_correction_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": "Not Found",
"originalRequest": {
"method": "PATCH",
"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 \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"description\": \"nisi \",\n \"duration\": 3600,\n \"end\": 1600000000,\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"start\": 1600000000,\n \"timezone\": \"UTC\"\n },\n \"type\": \"correction\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"correction",
":slo_correction_id"
],
"variable": [
{
"key": "slo_correction_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": "PATCH",
"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 \"data\": {\n \"attributes\": {\n \"category\": \"Scheduled Maintenance\",\n \"description\": \"nisi \",\n \"duration\": 3600,\n \"end\": 1600000000,\n \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n \"start\": 1600000000,\n \"timezone\": \"UTC\"\n },\n \"type\": \"correction\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
"correction",
":slo_correction_id"
],
"variable": [
{
"key": "slo_correction_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}"
}
]
}