Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "name": "My Dashboard",
// "author": {
// "email": "Excepteur id tempor cillum",
// "handle": "culpa nostrud pariatur",
// "name": "cillum minim"
// },
// "created": "1966-02-10T07:56:34.100Z",
// "dashboard_count": 38191328,
// "id": 17219875,
// "is_favorite": false,
// "modified": "1943-12-25T04:37:37.575Z",
// "type": "manual_dashboard_list"
// }
let json = CkoJsonObject()!
json.update("name", value: "My Dashboard")
json.update("author.email", value: "Excepteur id tempor cillum")
json.update("author.handle", value: "culpa nostrud pariatur")
json.update("author.name", value: "cillum minim")
json.update("created", value: "1966-02-10T07:56:34.100Z")
json.updateInt("dashboard_count", value: 38191328)
json.updateInt("id", value: 17219875)
json.updateBool("is_favorite", value: false)
json.update("modified", value: "1943-12-25T04:37:37.575Z")
json.update("type", value: "manual_dashboard_list")
http.setRequestHeader("Content-Type", value: "application/json")
http.setRequestHeader("Accept", value: "application/json")
let sbRequestBody = CkoStringBuilder()!
json.emitSb(sbRequestBody)
var resp: CkoHttpResponse? = http.pTextSb("PUT", url: "https://api.app.ddog-gov.com/api/v1/dashboard/lists/manual/:list_id", textData: sbRequestBody, charset: "utf-8", contentType: "application/json", md5: false, gzip: false)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "name": "My Dashboard",
// "author": {
// "email": "Excepteur id tempor cillum",
// "handle": "culpa nostrud pariatur",
// "name": "cillum minim"
// },
// "created": "1966-02-10T07:56:34.100Z",
// "dashboard_count": 38191328,
// "id": 17219875,
// "is_favorite": false,
// "modified": "1943-12-25T04:37:37.575Z",
// "type": "manual_dashboard_list"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var name: String? = jResp.string(of: "name")
var v_Email: String? = jResp.string(of: "author.email")
var Handle: String? = jResp.string(of: "author.handle")
var Name: String? = jResp.string(of: "author.name")
var created: String? = jResp.string(of: "created")
var dashboard_count: Int = jResp.int(of: "dashboard_count").intValue
var id: Int = jResp.int(of: "id").intValue
var is_favorite: Bool = jResp.bool(of: "is_favorite")
var modified: String? = jResp.string(of: "modified")
var v_type: String? = jResp.string(of: "type")
}
Curl Command
curl -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"name": "My Dashboard",
"author": {
"email": "Excepteur id tempor cillum",
"handle": "culpa nostrud pariatur",
"name": "cillum minim"
},
"created": "1966-02-10T07:56:34.100Z",
"dashboard_count": 38191328,
"id": 17219875,
"is_favorite": false,
"modified": "1943-12-25T04:37:37.575Z",
"type": "manual_dashboard_list"
}'
https://api.app.ddog-gov.com/api/v1/dashboard/lists/manual/:list_id
Postman Collection Item JSON
{
"name": "Update a dashboard list",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual",
":list_id"
],
"variable": [
{
"key": "list_id",
"value": "-62147425"
}
]
},
"description": "Update the name of a dashboard list."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "PUT",
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual",
":list_id"
],
"variable": [
{
"key": "list_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "PUT",
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual",
":list_id"
],
"variable": [
{
"key": "list_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": "PUT",
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual",
":list_id"
],
"variable": [
{
"key": "list_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": "PUT",
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual",
":list_id"
],
"variable": [
{
"key": "list_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": "PUT",
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual",
":list_id"
],
"variable": [
{
"key": "list_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}"
}
]
}