Chilkat Online Tools

delphiAx / Datadog API Collection / Get organization information

Back to Collection Items

var
http: TChilkatHttp;
success: Integer;
sbResponseBody: TChilkatStringBuilder;
jResp: TChilkatJsonObject;
respStatusCode: Integer;
strVal: WideString;
v_Type: WideString;
Created: WideString;
Description: WideString;
Name: WideString;
Public_id: WideString;
Private_widget_share: Integer;
Enabled: Integer;
Saml_autocreate_access_role: WideString;
Saml_autocreate_users_domainsEnabled: Integer;
Saml_can_be_enabled: Integer;
Saml_idp_endpoint: WideString;
Saml_idp_initiated_loginEnabled: Integer;
Saml_idp_metadata_uploaded: Integer;
Saml_login_url: WideString;
Saml_strict_modeEnabled: Integer;
SubscriptionType: WideString;
Trial: Integer;
i: Integer;
count_i: Integer;

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

http := TChilkatHttp.Create(Self);

http.SetRequestHeader('Accept','application/json');

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := http.QuickGetSb('https://api.app.ddog-gov.com/api/v1/org/:public_id',sbResponseBody.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

jResp := TChilkatJsonObject.Create(Self);
jResp.LoadSb(sbResponseBody.ControlInterface);
jResp.EmitCompact := 0;

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(jResp.Emit());

respStatusCode := http.LastStatus;
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(http.LastHeader);
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

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

// {
//   "org": {
//     "billing": {
//       "type": "parent_billing"
//     },
//     "created": "2019-09-26T17:28:28Z",
//     "description": "some description",
//     "name": "New child org",
//     "public_id": "abcdef12345",
//     "settings": {
//       "private_widget_share": false,
//       "saml": {
//         "enabled": false
//       },
//       "saml_autocreate_access_role": "ro",
//       "saml_autocreate_users_domains": {
//         "domains": [
//           "example.com",
//           "example.com"
//         ],
//         "enabled": false
//       },
//       "saml_can_be_enabled": false,
//       "saml_idp_endpoint": "https://my.saml.endpoint",
//       "saml_idp_initiated_login": {
//         "enabled": false
//       },
//       "saml_idp_metadata_uploaded": false,
//       "saml_login_url": "https://my.saml.login.url",
//       "saml_strict_mode": {
//         "enabled": false
//       }
//     },
//     "subscription": {
//       "type": "pro"
//     },
//     "trial": false
//   }
// }

// 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('org.billing.type');
Created := jResp.StringOf('org.created');
Description := jResp.StringOf('org.description');
Name := jResp.StringOf('org.name');
Public_id := jResp.StringOf('org.public_id');
Private_widget_share := jResp.BoolOf('org.settings.private_widget_share');
Enabled := jResp.BoolOf('org.settings.saml.enabled');
Saml_autocreate_access_role := jResp.StringOf('org.settings.saml_autocreate_access_role');
Saml_autocreate_users_domainsEnabled := jResp.BoolOf('org.settings.saml_autocreate_users_domains.enabled');
Saml_can_be_enabled := jResp.BoolOf('org.settings.saml_can_be_enabled');
Saml_idp_endpoint := jResp.StringOf('org.settings.saml_idp_endpoint');
Saml_idp_initiated_loginEnabled := jResp.BoolOf('org.settings.saml_idp_initiated_login.enabled');
Saml_idp_metadata_uploaded := jResp.BoolOf('org.settings.saml_idp_metadata_uploaded');
Saml_login_url := jResp.StringOf('org.settings.saml_login_url');
Saml_strict_modeEnabled := jResp.BoolOf('org.settings.saml_strict_mode.enabled');
SubscriptionType := jResp.StringOf('org.subscription.type');
Trial := jResp.BoolOf('org.trial');
i := 0;
count_i := jResp.SizeOfArray('org.settings.saml_autocreate_users_domains.domains');
while i < count_i do
  begin
    jResp.I := i;
    strVal := jResp.StringOf('org.settings.saml_autocreate_users_domains.domains[i]');
    i := i + 1;
  end;

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/org/:public_id

Postman Collection Item JSON

{
  "name": "Get organization information",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/org/:public_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "org",
        ":public_id"
      ],
      "variable": [
        {
          "key": "public_id",
          "value": "abc123"
        }
      ]
    },
    "description": "Get organization information."
  },
  "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/v1/org/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"org\": {\n    \"billing\": {\n      \"type\": \"parent_billing\"\n    },\n    \"created\": \"2019-09-26T17:28:28Z\",\n    \"description\": \"some description\",\n    \"name\": \"New child org\",\n    \"public_id\": \"abcdef12345\",\n    \"settings\": {\n      \"private_widget_share\": false,\n      \"saml\": {\n        \"enabled\": false\n      },\n      \"saml_autocreate_access_role\": \"ro\",\n      \"saml_autocreate_users_domains\": {\n        \"domains\": [\n          \"example.com\",\n          \"example.com\"\n        ],\n        \"enabled\": false\n      },\n      \"saml_can_be_enabled\": false,\n      \"saml_idp_endpoint\": \"https://my.saml.endpoint\",\n      \"saml_idp_initiated_login\": {\n        \"enabled\": false\n      },\n      \"saml_idp_metadata_uploaded\": false,\n      \"saml_login_url\": \"https://my.saml.login.url\",\n      \"saml_strict_mode\": {\n        \"enabled\": false\n      }\n    },\n    \"subscription\": {\n      \"type\": \"pro\"\n    },\n    \"trial\": false\n  }\n}"
    },
    {
      "name": "Bad Request",
      "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/v1/org/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_id"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Forbidden",
      "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/v1/org/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_id"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\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/v1/org/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_id"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    }
  ]
}