Chilkat Online Tools

VB6 / Datadog API Collection / Get a team

Back to Collection Items

' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim http As New ChilkatHttp
Dim success As Long

http.SetRequestHeader "Accept","application/json"

Dim sbResponseBody As New ChilkatStringBuilder
success = http.QuickGetSb("https://api.app.ddog-gov.com/api/v2/team/:team_id",sbResponseBody)
If (success = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0

Debug.Print "Response Body:"
Debug.Print jResp.Emit()

Dim respStatusCode As Long
respStatusCode = http.LastStatus
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Header:"
    Debug.Print http.LastHeader
    Debug.Print "Failed."
    Exit Sub
End If

' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)

' {
'   "data": {
'     "attributes": {
'       "handle": "<string>",
'       "name": "<string>",
'       "avatar": "<string>",
'       "banner": "<long>",
'       "created_at": "<dateTime>",
'       "description": "<string>",
'       "hidden_modules": [
'         "<string>",
'         "<string>"
'       ],
'       "link_count": "<integer>",
'       "modified_at": "<dateTime>",
'       "summary": "<string>",
'       "user_count": "<integer>",
'       "visible_modules": [
'         "<string>",
'         "<string>"
'       ]
'     },
'     "id": "<string>",
'     "type": "team",
'     "relationships": {
'       "team_links": {
'         "data": [
'           {
'             "id": "<string>",
'             "type": "team_links"
'           },
'           {
'             "id": "<string>",
'             "type": "team_links"
'           }
'         ],
'         "links": {
'           "related": "<string>"
'         }
'       },
'       "user_team_permissions": {
'         "data": {
'           "id": "<string>",
'           "type": "user_team_permissions"
'         },
'         "links": {
'           "related": "<string>"
'         }
'       }
'     }
'   }
' }

' Sample code for parsing the JSON response...
' Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

Dim strVal As String
Dim id As String
Dim v_type As String

Dim Handle As String
Handle = jResp.StringOf("data.attributes.handle")
Dim Name As String
Name = jResp.StringOf("data.attributes.name")
Dim Avatar As String
Avatar = jResp.StringOf("data.attributes.avatar")
Dim Banner As String
Banner = jResp.StringOf("data.attributes.banner")
Dim Created_at As String
Created_at = jResp.StringOf("data.attributes.created_at")
Dim Description As String
Description = jResp.StringOf("data.attributes.description")
Dim Link_count As String
Link_count = jResp.StringOf("data.attributes.link_count")
Dim Modified_at As String
Modified_at = jResp.StringOf("data.attributes.modified_at")
Dim Summary As String
Summary = jResp.StringOf("data.attributes.summary")
Dim User_count As String
User_count = jResp.StringOf("data.attributes.user_count")
Dim Id As String
Id = jResp.StringOf("data.id")
Dim v_Type As String
v_Type = jResp.StringOf("data.type")
Dim Related As String
Related = jResp.StringOf("data.relationships.team_links.links.related")
Dim DataId As String
DataId = jResp.StringOf("data.relationships.user_team_permissions.data.id")
Dim DataType As String
DataType = jResp.StringOf("data.relationships.user_team_permissions.data.type")
Dim LinksRelated As String
LinksRelated = jResp.StringOf("data.relationships.user_team_permissions.links.related")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("data.attributes.hidden_modules")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("data.attributes.hidden_modules[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("data.attributes.visible_modules")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("data.attributes.visible_modules[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("data.relationships.team_links.data")
Do While i < count_i
    jResp.I = i
    id = jResp.StringOf("data.relationships.team_links.data[i].id")
    v_type = jResp.StringOf("data.relationships.team_links.data[i].type")
    i = i + 1
Loop

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/team/:team_id

Postman Collection Item JSON

{
  "name": "Get a team",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/team/:team_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "team",
        ":team_id"
      ],
      "variable": [
        {
          "key": "team_id",
          "value": "<string>"
        }
      ]
    },
    "description": "Get a single team using the team's `id`."
  },
  "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/team/:team_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "team",
            ":team_id"
          ],
          "variable": [
            {
              "key": "team_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"attributes\": {\n      \"handle\": \"<string>\",\n      \"name\": \"<string>\",\n      \"avatar\": \"<string>\",\n      \"banner\": \"<long>\",\n      \"created_at\": \"<dateTime>\",\n      \"description\": \"<string>\",\n      \"hidden_modules\": [\n        \"<string>\",\n        \"<string>\"\n      ],\n      \"link_count\": \"<integer>\",\n      \"modified_at\": \"<dateTime>\",\n      \"summary\": \"<string>\",\n      \"user_count\": \"<integer>\",\n      \"visible_modules\": [\n        \"<string>\",\n        \"<string>\"\n      ]\n    },\n    \"id\": \"<string>\",\n    \"type\": \"team\",\n    \"relationships\": {\n      \"team_links\": {\n        \"data\": [\n          {\n            \"id\": \"<string>\",\n            \"type\": \"team_links\"\n          },\n          {\n            \"id\": \"<string>\",\n            \"type\": \"team_links\"\n          }\n        ],\n        \"links\": {\n          \"related\": \"<string>\"\n        }\n      },\n      \"user_team_permissions\": {\n        \"data\": {\n          \"id\": \"<string>\",\n          \"type\": \"user_team_permissions\"\n        },\n        \"links\": {\n          \"related\": \"<string>\"\n        }\n      }\n    }\n  }\n}"
    },
    {
      "name": "API error response.",
      "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/team/:team_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "team",
            ":team_id"
          ],
          "variable": [
            {
              "key": "team_id"
            }
          ]
        }
      },
      "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": "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/team/:team_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "team",
            ":team_id"
          ],
          "variable": [
            {
              "key": "team_id"
            }
          ]
        }
      },
      "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}"
    }
  ]
}