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.
; {
; "filter": {
; "from": "now-15m",
; "query": "*",
; "to": "now"
; },
; "options": {
; "time_offset": "<long>",
; "timezone": "UTC"
; },
; "page": {
; "cursor": "<string>",
; "limit": 10
; },
; "sort": "-timestamp"
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("filter.from","now-15m")
$oJson.UpdateString("filter.query","*")
$oJson.UpdateString("filter.to","now")
$oJson.UpdateString("options.time_offset","<long>")
$oJson.UpdateString("options.timezone","UTC")
$oJson.UpdateString("page.cursor","<string>")
$oJson.UpdateInt("page.limit",10)
$oJson.UpdateString("sort","-timestamp")
$oHttp.SetRequestHeader "Content-Type","application/json"
$oHttp.SetRequestHeader "Accept","application/json"
Local $oResp = $oHttp.PostJson3("https://api.app.ddog-gov.com/api/v2/rum/events/search","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": [
; {
; "attributes": {
; "attributes": {
; "ea___6": {},
; "et15": {},
; "amet_0": {}
; },
; "service": "<string>",
; "tags": [
; "<string>",
; "<string>"
; ],
; "timestamp": "<dateTime>"
; },
; "id": "<string>",
; "type": "rum"
; },
; {
; "attributes": {
; "attributes": {
; "dolore_a0": {},
; "officia5": {}
; },
; "service": "<string>",
; "tags": [
; "<string>",
; "<string>"
; ],
; "timestamp": "<dateTime>"
; },
; "id": "<string>",
; "type": "rum"
; }
; ],
; "links": {
; "next": "<string>"
; },
; "meta": {
; "elapsed": "<long>",
; "page": {
; "after": "<string>"
; },
; "request_id": "<string>",
; "status": "done",
; "warnings": [
; {
; "code": "<string>",
; "detail": "<string>",
; "title": "<string>"
; },
; {
; "code": "<string>",
; "detail": "<string>",
; "title": "<string>"
; }
; ]
; }
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Local $sService
Local $sTimestamp
Local $sId
Local $sV_type
Local $iJ
Local $iCount_j
Local $strVal
Local $sCode
Local $sDetail
Local $sTitle
Local $sV_Next = $oJResp.StringOf("links.next")
Local $sElapsed = $oJResp.StringOf("meta.elapsed")
Local $sAfter = $oJResp.StringOf("meta.page.after")
Local $sRequest_id = $oJResp.StringOf("meta.request_id")
Local $sStatus = $oJResp.StringOf("meta.status")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("data")
While $i < $iCount_i
$oJResp.I = $i
$sService = $oJResp.StringOf("data[i].attributes.service")
$sTimestamp = $oJResp.StringOf("data[i].attributes.timestamp")
$sId = $oJResp.StringOf("data[i].id")
$sV_type = $oJResp.StringOf("data[i].type")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("data[i].attributes.tags")
While $iJ < $iCount_j
$oJResp.J = $iJ
$strVal = $oJResp.StringOf("data[i].attributes.tags[j]")
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("meta.warnings")
While $i < $iCount_i
$oJResp.I = $i
$sCode = $oJResp.StringOf("meta.warnings[i].code")
$sDetail = $oJResp.StringOf("meta.warnings[i].detail")
$sTitle = $oJResp.StringOf("meta.warnings[i].title")
$i = $i + 1
Wend
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"filter": {
"from": "now-15m",
"query": "*",
"to": "now"
},
"options": {
"time_offset": "<long>",
"timezone": "UTC"
},
"page": {
"cursor": "<string>",
"limit": 10
},
"sort": "-timestamp"
}'
https://api.app.ddog-gov.com/api/v2/rum/events/search
Postman Collection Item JSON
{
"name": "Search RUM events",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n },\n \"page\": {\n \"cursor\": \"<string>\",\n \"limit\": 10\n },\n \"sort\": \"-timestamp\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/rum/events/search",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"rum",
"events",
"search"
]
},
"description": "List endpoint returns RUM events that match a RUM search query.\n[Results are paginated][1].\n\nUse this endpoint to build complex RUM events filtering and search.\n\n[1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination"
},
"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 \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n },\n \"page\": {\n \"cursor\": \"<string>\",\n \"limit\": 10\n },\n \"sort\": \"-timestamp\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/rum/events/search",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"rum",
"events",
"search"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\n \"attributes\": {\n \"attributes\": {\n \"ea___6\": {},\n \"et15\": {},\n \"amet_0\": {}\n },\n \"service\": \"<string>\",\n \"tags\": [\n \"<string>\",\n \"<string>\"\n ],\n \"timestamp\": \"<dateTime>\"\n },\n \"id\": \"<string>\",\n \"type\": \"rum\"\n },\n {\n \"attributes\": {\n \"attributes\": {\n \"dolore_a0\": {},\n \"officia5\": {}\n },\n \"service\": \"<string>\",\n \"tags\": [\n \"<string>\",\n \"<string>\"\n ],\n \"timestamp\": \"<dateTime>\"\n },\n \"id\": \"<string>\",\n \"type\": \"rum\"\n }\n ],\n \"links\": {\n \"next\": \"<string>\"\n },\n \"meta\": {\n \"elapsed\": \"<long>\",\n \"page\": {\n \"after\": \"<string>\"\n },\n \"request_id\": \"<string>\",\n \"status\": \"done\",\n \"warnings\": [\n {\n \"code\": \"<string>\",\n \"detail\": \"<string>\",\n \"title\": \"<string>\"\n },\n {\n \"code\": \"<string>\",\n \"detail\": \"<string>\",\n \"title\": \"<string>\"\n }\n ]\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 \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n },\n \"page\": {\n \"cursor\": \"<string>\",\n \"limit\": 10\n },\n \"sort\": \"-timestamp\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/rum/events/search",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"rum",
"events",
"search"
]
}
},
"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": "Not Authorized",
"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 \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n },\n \"page\": {\n \"cursor\": \"<string>\",\n \"limit\": 10\n },\n \"sort\": \"-timestamp\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/rum/events/search",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"rum",
"events",
"search"
]
}
},
"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 \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n },\n \"page\": {\n \"cursor\": \"<string>\",\n \"limit\": 10\n },\n \"sort\": \"-timestamp\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/rum/events/search",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"rum",
"events",
"search"
]
}
},
"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}"
}
]
}