Chilkat Online Tools

autoit / Datadog API Collection / Update your organization

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_9_5_0.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.

; {
;   "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
; }

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("billing.type","parent_billing")
$oJson.UpdateString("created","2019-09-26T17:28:28Z")
$oJson.UpdateString("description","some description")
$oJson.UpdateString("name","New child org")
$oJson.UpdateString("public_id","abcdef12345")
$oJson.UpdateBool("settings.private_widget_share",False)
$oJson.UpdateBool("settings.saml.enabled",False)
$oJson.UpdateString("settings.saml_autocreate_access_role","ro")
$oJson.UpdateString("settings.saml_autocreate_users_domains.domains[0]","example.com")
$oJson.UpdateString("settings.saml_autocreate_users_domains.domains[1]","example.com")
$oJson.UpdateBool("settings.saml_autocreate_users_domains.enabled",False)
$oJson.UpdateBool("settings.saml_can_be_enabled",False)
$oJson.UpdateString("settings.saml_idp_endpoint","https://my.saml.endpoint")
$oJson.UpdateBool("settings.saml_idp_initiated_login.enabled",False)
$oJson.UpdateBool("settings.saml_idp_metadata_uploaded",False)
$oJson.UpdateString("settings.saml_login_url","https://my.saml.login.url")
$oJson.UpdateBool("settings.saml_strict_mode.enabled",False)
$oJson.UpdateString("subscription.type","pro")
$oJson.UpdateBool("trial",False)

$oHttp.SetRequestHeader "Content-Type","application/json"
$oHttp.SetRequestHeader "Accept","application/json"

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)

Local $oResp = $oHttp.PTextSb("PUT","https://api.app.ddog-gov.com/api/v1/org/:public_id",$oSbRequestBody,"utf-8","application/json",False,False)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)

$oJResp = ObjCreate("Chilkat_9_5_0.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)

; {
;   "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

Local $strVal

Local $sV_Type = $oJResp.StringOf("org.billing.type")
Local $sCreated = $oJResp.StringOf("org.created")
Local $sDescription = $oJResp.StringOf("org.description")
Local $sName = $oJResp.StringOf("org.name")
Local $sPublic_id = $oJResp.StringOf("org.public_id")
Local $bPrivate_widget_share = $oJResp.BoolOf("org.settings.private_widget_share")
Local $bEnabled = $oJResp.BoolOf("org.settings.saml.enabled")
Local $sSaml_autocreate_access_role = $oJResp.StringOf("org.settings.saml_autocreate_access_role")
Local $bSaml_autocreate_users_domainsEnabled = $oJResp.BoolOf("org.settings.saml_autocreate_users_domains.enabled")
Local $bSaml_can_be_enabled = $oJResp.BoolOf("org.settings.saml_can_be_enabled")
Local $sSaml_idp_endpoint = $oJResp.StringOf("org.settings.saml_idp_endpoint")
Local $bSaml_idp_initiated_loginEnabled = $oJResp.BoolOf("org.settings.saml_idp_initiated_login.enabled")
Local $bSaml_idp_metadata_uploaded = $oJResp.BoolOf("org.settings.saml_idp_metadata_uploaded")
Local $sSaml_login_url = $oJResp.StringOf("org.settings.saml_login_url")
Local $bSaml_strict_modeEnabled = $oJResp.BoolOf("org.settings.saml_strict_mode.enabled")
Local $sSubscriptionType = $oJResp.StringOf("org.subscription.type")
Local $bTrial = $oJResp.BoolOf("org.trial")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("org.settings.saml_autocreate_users_domains.domains")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("org.settings.saml_autocreate_users_domains.domains[i]")
    $i = $i + 1
Wend

Curl Command

curl -X PUT
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "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
}'
https://api.app.ddog-gov.com/api/v1/org/:public_id

Postman Collection Item JSON

{
  "name": "Update your organization",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\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}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v1/org/:public_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "org",
        ":public_id"
      ],
      "variable": [
        {
          "key": "public_id",
          "value": "abc123"
        }
      ]
    },
    "description": "Update your organization."
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "PUT",
        "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  \"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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "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": "PUT",
        "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  \"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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "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": "PUT",
        "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  \"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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "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": "PUT",
        "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  \"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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "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}"
    }
  ]
}