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.
// {
// "index_names": [
// "main",
// "payments",
// "web"
// ]
// }
let json = CkoJsonObject()!
json.update("index_names[0]", value: "main")
json.update("index_names[1]", value: "payments")
json.update("index_names[2]", value: "web")
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/logs/config/index-order", 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)
// {
// "index_names": [
// "main",
// "payments",
// "web"
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var strVal: String?
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "index_names").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "index_names[i]")
i = i + 1
}
}
Curl Command
curl -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"index_names": [
"main",
"payments",
"web"
]
}'
https://api.app.ddog-gov.com/api/v1/logs/config/index-order
Postman Collection Item JSON
{
"name": "Update indexes order",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"index_names\": [\n \"main\",\n \"payments\",\n \"web\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/index-order",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"index-order"
]
},
"description": "This endpoint updates the index order of your organization.\nIt returns the index order object passed in the request body when the request is successful."
},
"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 \"index_names\": [\n \"main\",\n \"payments\",\n \"web\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/index-order",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"index-order"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"index_names\": [\n \"main\",\n \"payments\",\n \"web\"\n ]\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 \"index_names\": [\n \"main\",\n \"payments\",\n \"web\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/index-order",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"index-order"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "null"
},
{
"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 \"index_names\": [\n \"main\",\n \"payments\",\n \"web\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/index-order",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"index-order"
]
}
},
"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": "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 \"index_names\": [\n \"main\",\n \"payments\",\n \"web\"\n ]\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/index-order",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"index-order"
]
}
},
"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}"
}
]
}