Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; 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": {
; "type": "archives",
; "attributes": {
; "name": "<string>",
; "query": "<string>",
; "destination": {
; "storage_account": "<string>",
; "container": "<string>",
; "integration": {
; "tenant_id": "<string>",
; "client_id": "<string>"
; },
; "type": "azure",
; "path": "<string>",
; "region": "<string>"
; },
; "include_tags": false,
; "rehydration_max_scan_size_in_gb": "<long>",
; "rehydration_tags": [
; "<string>",
; "<string>"
; ]
; }
; }
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("data.type","archives")
$oJson.UpdateString("data.attributes.name","<string>")
$oJson.UpdateString("data.attributes.query","<string>")
$oJson.UpdateString("data.attributes.destination.storage_account","<string>")
$oJson.UpdateString("data.attributes.destination.container","<string>")
$oJson.UpdateString("data.attributes.destination.integration.tenant_id","<string>")
$oJson.UpdateString("data.attributes.destination.integration.client_id","<string>")
$oJson.UpdateString("data.attributes.destination.type","azure")
$oJson.UpdateString("data.attributes.destination.path","<string>")
$oJson.UpdateString("data.attributes.destination.region","<string>")
$oJson.UpdateBool("data.attributes.include_tags",False)
$oJson.UpdateString("data.attributes.rehydration_max_scan_size_in_gb","<long>")
$oJson.UpdateString("data.attributes.rehydration_tags[0]","<string>")
$oJson.UpdateString("data.attributes.rehydration_tags[1]","<string>")
$oHttp.SetRequestHeader "Content-Type","application/json"
$oHttp.SetRequestHeader "Accept","application/json"
Local $oResp = $oHttp.PostJson3("https://api.app.ddog-gov.com/api/v2/logs/config/archives","application/json",$oJson)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oResp.Header & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "data": {
; "type": "archives",
; "attributes": {
; "name": "<string>",
; "query": "<string>",
; "destination": {
; "storage_account": "<string>",
; "container": "<string>",
; "integration": {
; "tenant_id": "<string>",
; "client_id": "<string>"
; },
; "type": "azure",
; "path": "<string>",
; "region": "<string>"
; },
; "include_tags": false,
; "rehydration_max_scan_size_in_gb": "<long>",
; "rehydration_tags": [
; "<string>",
; "<string>"
; ],
; "state": "FAILING"
; },
; "id": "<string>"
; }
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Local $strVal
Local $sV_Type = $oJResp.StringOf("data.type")
Local $sName = $oJResp.StringOf("data.attributes.name")
Local $sQuery = $oJResp.StringOf("data.attributes.query")
Local $sStorage_account = $oJResp.StringOf("data.attributes.destination.storage_account")
Local $sContainer = $oJResp.StringOf("data.attributes.destination.container")
Local $sTenant_id = $oJResp.StringOf("data.attributes.destination.integration.tenant_id")
Local $sClient_id = $oJResp.StringOf("data.attributes.destination.integration.client_id")
Local $sDestinationType = $oJResp.StringOf("data.attributes.destination.type")
Local $sPath = $oJResp.StringOf("data.attributes.destination.path")
Local $sRegion = $oJResp.StringOf("data.attributes.destination.region")
Local $bInclude_tags = $oJResp.BoolOf("data.attributes.include_tags")
Local $sRehydration_max_scan_size_in_gb = $oJResp.StringOf("data.attributes.rehydration_max_scan_size_in_gb")
Local $sState = $oJResp.StringOf("data.attributes.state")
Local $sId = $oJResp.StringOf("data.id")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("data.attributes.rehydration_tags")
While $i < $iCount_i
$oJResp.I = $i
$strVal = $oJResp.StringOf("data.attributes.rehydration_tags[i]")
$i = $i + 1
Wend
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"data": {
"type": "archives",
"attributes": {
"name": "<string>",
"query": "<string>",
"destination": {
"storage_account": "<string>",
"container": "<string>",
"integration": {
"tenant_id": "<string>",
"client_id": "<string>"
},
"type": "azure",
"path": "<string>",
"region": "<string>"
},
"include_tags": false,
"rehydration_max_scan_size_in_gb": "<long>",
"rehydration_tags": [
"<string>",
"<string>"
]
}
}
}'
https://api.app.ddog-gov.com/api/v2/logs/config/archives
Postman Collection Item JSON
{
"name": "Create an archive",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"type\": \"archives\",\n \"attributes\": {\n \"name\": \"<string>\",\n \"query\": \"<string>\",\n \"destination\": {\n \"storage_account\": \"<string>\",\n \"container\": \"<string>\",\n \"integration\": {\n \"tenant_id\": \"<string>\",\n \"client_id\": \"<string>\"\n },\n \"type\": \"azure\",\n \"path\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"include_tags\": false,\n \"rehydration_max_scan_size_in_gb\": \"<long>\",\n \"rehydration_tags\": [\n \"<string>\",\n \"<string>\"\n ]\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/logs/config/archives",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"logs",
"config",
"archives"
]
},
"description": "Create an archive in your organization."
},
"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 \"data\": {\n \"type\": \"archives\",\n \"attributes\": {\n \"name\": \"<string>\",\n \"query\": \"<string>\",\n \"destination\": {\n \"storage_account\": \"<string>\",\n \"container\": \"<string>\",\n \"integration\": {\n \"tenant_id\": \"<string>\",\n \"client_id\": \"<string>\"\n },\n \"type\": \"azure\",\n \"path\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"include_tags\": false,\n \"rehydration_max_scan_size_in_gb\": \"<long>\",\n \"rehydration_tags\": [\n \"<string>\",\n \"<string>\"\n ]\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/logs/config/archives",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"logs",
"config",
"archives"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"type\": \"archives\",\n \"attributes\": {\n \"name\": \"<string>\",\n \"query\": \"<string>\",\n \"destination\": {\n \"storage_account\": \"<string>\",\n \"container\": \"<string>\",\n \"integration\": {\n \"tenant_id\": \"<string>\",\n \"client_id\": \"<string>\"\n },\n \"type\": \"azure\",\n \"path\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"include_tags\": false,\n \"rehydration_max_scan_size_in_gb\": \"<long>\",\n \"rehydration_tags\": [\n \"<string>\",\n \"<string>\"\n ],\n \"state\": \"FAILING\"\n },\n \"id\": \"<string>\"\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 \"data\": {\n \"type\": \"archives\",\n \"attributes\": {\n \"name\": \"<string>\",\n \"query\": \"<string>\",\n \"destination\": {\n \"storage_account\": \"<string>\",\n \"container\": \"<string>\",\n \"integration\": {\n \"tenant_id\": \"<string>\",\n \"client_id\": \"<string>\"\n },\n \"type\": \"azure\",\n \"path\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"include_tags\": false,\n \"rehydration_max_scan_size_in_gb\": \"<long>\",\n \"rehydration_tags\": [\n \"<string>\",\n \"<string>\"\n ]\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/logs/config/archives",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"logs",
"config",
"archives"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\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 \"data\": {\n \"type\": \"archives\",\n \"attributes\": {\n \"name\": \"<string>\",\n \"query\": \"<string>\",\n \"destination\": {\n \"storage_account\": \"<string>\",\n \"container\": \"<string>\",\n \"integration\": {\n \"tenant_id\": \"<string>\",\n \"client_id\": \"<string>\"\n },\n \"type\": \"azure\",\n \"path\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"include_tags\": false,\n \"rehydration_max_scan_size_in_gb\": \"<long>\",\n \"rehydration_tags\": [\n \"<string>\",\n \"<string>\"\n ]\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/logs/config/archives",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"logs",
"config",
"archives"
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\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 \"data\": {\n \"type\": \"archives\",\n \"attributes\": {\n \"name\": \"<string>\",\n \"query\": \"<string>\",\n \"destination\": {\n \"storage_account\": \"<string>\",\n \"container\": \"<string>\",\n \"integration\": {\n \"tenant_id\": \"<string>\",\n \"client_id\": \"<string>\"\n },\n \"type\": \"azure\",\n \"path\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"include_tags\": false,\n \"rehydration_max_scan_size_in_gb\": \"<long>\",\n \"rehydration_tags\": [\n \"<string>\",\n \"<string>\"\n ]\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/logs/config/archives",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"logs",
"config",
"archives"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
}
]
}