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
$oHttp.SetRequestHeader "Accept","application/json"
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://api.app.ddog-gov.com/api/v2/apm/config/retention-filters",$oSbResponseBody)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oHttp.LastHeader & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "data": [
; {
; "id": "<string>",
; "type": "apm_retention_filter",
; "attributes": {
; "created_at": "<long>",
; "created_by": "<string>",
; "editable": "<boolean>",
; "enabled": "<boolean>",
; "execution_order": "<long>",
; "filter": {
; "query": "<string>"
; },
; "filter_type": "spans-sampling-processor",
; "modified_at": "<long>",
; "modified_by": "<string>",
; "name": "<string>",
; "rate": "<double>"
; }
; },
; {
; "id": "<string>",
; "type": "apm_retention_filter",
; "attributes": {
; "created_at": "<long>",
; "created_by": "<string>",
; "editable": "<boolean>",
; "enabled": "<boolean>",
; "execution_order": "<long>",
; "filter": {
; "query": "<string>"
; },
; "filter_type": "spans-sampling-processor",
; "modified_at": "<long>",
; "modified_by": "<string>",
; "name": "<string>",
; "rate": "<double>"
; }
; }
; ]
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Local $sId
Local $sV_type
Local $sCreated_at
Local $sCreated_by
Local $sEditable
Local $sEnabled
Local $sExecution_order
Local $sQuery
Local $sFilter_type
Local $sModified_at
Local $sModified_by
Local $sName
Local $sRate
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("data")
While $i < $iCount_i
$oJResp.I = $i
$sId = $oJResp.StringOf("data[i].id")
$sV_type = $oJResp.StringOf("data[i].type")
$sCreated_at = $oJResp.StringOf("data[i].attributes.created_at")
$sCreated_by = $oJResp.StringOf("data[i].attributes.created_by")
$sEditable = $oJResp.StringOf("data[i].attributes.editable")
$sEnabled = $oJResp.StringOf("data[i].attributes.enabled")
$sExecution_order = $oJResp.StringOf("data[i].attributes.execution_order")
$sQuery = $oJResp.StringOf("data[i].attributes.filter.query")
$sFilter_type = $oJResp.StringOf("data[i].attributes.filter_type")
$sModified_at = $oJResp.StringOf("data[i].attributes.modified_at")
$sModified_by = $oJResp.StringOf("data[i].attributes.modified_by")
$sName = $oJResp.StringOf("data[i].attributes.name")
$sRate = $oJResp.StringOf("data[i].attributes.rate")
$i = $i + 1
Wend
Curl Command
curl -X GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/apm/config/retention-filters
Postman Collection Item JSON
{
"name": "List all APM retention filters",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
},
"description": "Get the list of APM retention filters."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\n \"id\": \"<string>\",\n \"type\": \"apm_retention_filter\",\n \"attributes\": {\n \"created_at\": \"<long>\",\n \"created_by\": \"<string>\",\n \"editable\": \"<boolean>\",\n \"enabled\": \"<boolean>\",\n \"execution_order\": \"<long>\",\n \"filter\": {\n \"query\": \"<string>\"\n },\n \"filter_type\": \"spans-sampling-processor\",\n \"modified_at\": \"<long>\",\n \"modified_by\": \"<string>\",\n \"name\": \"<string>\",\n \"rate\": \"<double>\"\n }\n },\n {\n \"id\": \"<string>\",\n \"type\": \"apm_retention_filter\",\n \"attributes\": {\n \"created_at\": \"<long>\",\n \"created_by\": \"<string>\",\n \"editable\": \"<boolean>\",\n \"enabled\": \"<boolean>\",\n \"execution_order\": \"<long>\",\n \"filter\": {\n \"query\": \"<string>\"\n },\n \"filter_type\": \"spans-sampling-processor\",\n \"modified_at\": \"<long>\",\n \"modified_by\": \"<string>\",\n \"name\": \"<string>\",\n \"rate\": \"<double>\"\n }\n }\n ]\n}"
},
{
"name": "Not Authorized",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
}
},
"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": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
}
},
"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}"
}
]
}