Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = CreateObject("Chilkat.Http")
' 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": "ip_allowlist",
' "attributes": {
' "enabled": "<boolean>",
' "entries": [
' {
' "data": {
' "type": "ip_allowlist_entry",
' "attributes": {
' "cidr_block": "<string>",
' "created_at": "<dateTime>",
' "modified_at": "<dateTime>",
' "note": "<string>"
' },
' "id": "<string>"
' }
' },
' {
' "data": {
' "type": "ip_allowlist_entry",
' "attributes": {
' "cidr_block": "<string>",
' "created_at": "<dateTime>",
' "modified_at": "<dateTime>",
' "note": "<string>"
' },
' "id": "<string>"
' }
' }
' ]
' },
' "id": "<string>"
' }
' }
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = CreateObject("Chilkat.JsonObject")
success = json.UpdateString("data.type","ip_allowlist")
success = json.UpdateString("data.attributes.enabled","<boolean>")
success = json.UpdateString("data.attributes.entries[0].data.type","ip_allowlist_entry")
success = json.UpdateString("data.attributes.entries[0].data.attributes.cidr_block","<string>")
success = json.UpdateString("data.attributes.entries[0].data.attributes.created_at","<dateTime>")
success = json.UpdateString("data.attributes.entries[0].data.attributes.modified_at","<dateTime>")
success = json.UpdateString("data.attributes.entries[0].data.attributes.note","<string>")
success = json.UpdateString("data.attributes.entries[0].data.id","<string>")
success = json.UpdateString("data.attributes.entries[1].data.type","ip_allowlist_entry")
success = json.UpdateString("data.attributes.entries[1].data.attributes.cidr_block","<string>")
success = json.UpdateString("data.attributes.entries[1].data.attributes.created_at","<dateTime>")
success = json.UpdateString("data.attributes.entries[1].data.attributes.modified_at","<dateTime>")
success = json.UpdateString("data.attributes.entries[1].data.attributes.note","<string>")
success = json.UpdateString("data.attributes.entries[1].data.id","<string>")
success = json.UpdateString("data.id","<string>")
http.SetRequestHeader "Content-Type","application/json"
http.SetRequestHeader "Accept","application/json"
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbRequestBody = CreateObject("Chilkat.StringBuilder")
success = json.EmitSb(sbRequestBody)
' resp is a Chilkat.HttpResponse
Set resp = http.PTextSb("PATCH","https://api.app.ddog-gov.com/api/v2/ip_allowlist",sbRequestBody,"utf-8","application/json",0,0)
If (http.LastMethodSuccess = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbResponseBody = CreateObject("Chilkat.StringBuilder")
success = resp.GetBodySb(sbResponseBody)
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jResp = CreateObject("Chilkat.JsonObject")
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
outFile.WriteLine("Response Body:")
outFile.WriteLine(jResp.Emit())
respStatusCode = resp.StatusCode
outFile.WriteLine("Response Status Code = " & respStatusCode)
If (respStatusCode >= 400) Then
outFile.WriteLine("Response Header:")
outFile.WriteLine(resp.Header)
outFile.WriteLine("Failed.")
WScript.Quit
End If
' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)
' {
' "data": {
' "type": "ip_allowlist",
' "attributes": {
' "enabled": "<boolean>",
' "entries": [
' {
' "data": {
' "type": "ip_allowlist_entry",
' "attributes": {
' "cidr_block": "<string>",
' "created_at": "<dateTime>",
' "modified_at": "<dateTime>",
' "note": "<string>"
' },
' "id": "<string>"
' }
' },
' {
' "data": {
' "type": "ip_allowlist_entry",
' "attributes": {
' "cidr_block": "<string>",
' "created_at": "<dateTime>",
' "modified_at": "<dateTime>",
' "note": "<string>"
' },
' "id": "<string>"
' }
' }
' ]
' },
' "id": "<string>"
' }
' }
' Sample code for parsing the JSON response...
' Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
v_Type = jResp.StringOf("data.type")
Enabled = jResp.StringOf("data.attributes.enabled")
Id = jResp.StringOf("data.id")
i = 0
count_i = jResp.SizeOfArray("data.attributes.entries")
Do While i < count_i
jResp.I = i
dataType = jResp.StringOf("data.attributes.entries[i].data.type")
Cidr_block = jResp.StringOf("data.attributes.entries[i].data.attributes.cidr_block")
Created_at = jResp.StringOf("data.attributes.entries[i].data.attributes.created_at")
Modified_at = jResp.StringOf("data.attributes.entries[i].data.attributes.modified_at")
Note = jResp.StringOf("data.attributes.entries[i].data.attributes.note")
dataId = jResp.StringOf("data.attributes.entries[i].data.id")
i = i + 1
Loop
outFile.Close
Curl Command
curl -X PATCH
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"data": {
"type": "ip_allowlist",
"attributes": {
"enabled": "<boolean>",
"entries": [
{
"data": {
"type": "ip_allowlist_entry",
"attributes": {
"cidr_block": "<string>",
"created_at": "<dateTime>",
"modified_at": "<dateTime>",
"note": "<string>"
},
"id": "<string>"
}
},
{
"data": {
"type": "ip_allowlist_entry",
"attributes": {
"cidr_block": "<string>",
"created_at": "<dateTime>",
"modified_at": "<dateTime>",
"note": "<string>"
},
"id": "<string>"
}
}
]
},
"id": "<string>"
}
}'
https://api.app.ddog-gov.com/api/v2/ip_allowlist
Postman Collection Item JSON
{
"name": "Update IP Allowlist",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"type\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ip_allowlist",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ip_allowlist"
]
},
"description": "Edit the entries in the IP allowlist, and enable or disable it."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "PATCH",
"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\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ip_allowlist",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ip_allowlist"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"type\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "PATCH",
"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\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ip_allowlist",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ip_allowlist"
]
}
},
"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": "PATCH",
"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\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ip_allowlist",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ip_allowlist"
]
}
},
"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": "Not Found",
"originalRequest": {
"method": "PATCH",
"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\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ip_allowlist",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ip_allowlist"
]
}
},
"status": "Not Found",
"code": 404,
"_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": "PATCH",
"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\": \"ip_allowlist\",\n \"attributes\": {\n \"enabled\": \"<boolean>\",\n \"entries\": [\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n },\n {\n \"data\": {\n \"type\": \"ip_allowlist_entry\",\n \"attributes\": {\n \"cidr_block\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"modified_at\": \"<dateTime>\",\n \"note\": \"<string>\"\n },\n \"id\": \"<string>\"\n }\n }\n ]\n },\n \"id\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ip_allowlist",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ip_allowlist"
]
}
},
"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}"
}
]
}