Chilkat Online Tools

VB.NET / 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.

Dim http As New Chilkat.Http
Dim success As Boolean

' 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
' }

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

http.SetRequestHeader("Content-Type","application/json")
http.SetRequestHeader("Accept","application/json")

Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)

Dim resp As Chilkat.HttpResponse = http.PTextSb("PUT","https://api.app.ddog-gov.com/api/v1/org/:public_id",sbRequestBody,"utf-8","application/json",False,False)
If (http.LastMethodSuccess = False) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


Dim sbResponseBody As New Chilkat.StringBuilder
resp.GetBodySb(sbResponseBody)

Dim jResp As New Chilkat.JsonObject
jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

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

Dim respStatusCode As Integer = resp.StatusCode
Debug.WriteLine("Response Status Code = " & respStatusCode)
If (respStatusCode >= 400) Then
    Debug.WriteLine("Response Header:")
    Debug.WriteLine(resp.Header)
    Debug.WriteLine("Failed.")

    Exit Sub
End If



' 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



Dim strVal As String

Dim v_Type As String = jResp.StringOf("org.billing.type")
Dim Created As String = jResp.StringOf("org.created")
Dim Description As String = jResp.StringOf("org.description")
Dim Name As String = jResp.StringOf("org.name")
Dim Public_id As String = jResp.StringOf("org.public_id")
Dim Private_widget_share As Boolean = jResp.BoolOf("org.settings.private_widget_share")
Dim Enabled As Boolean = jResp.BoolOf("org.settings.saml.enabled")
Dim Saml_autocreate_access_role As String = jResp.StringOf("org.settings.saml_autocreate_access_role")
Dim Saml_autocreate_users_domainsEnabled As Boolean = jResp.BoolOf("org.settings.saml_autocreate_users_domains.enabled")
Dim Saml_can_be_enabled As Boolean = jResp.BoolOf("org.settings.saml_can_be_enabled")
Dim Saml_idp_endpoint As String = jResp.StringOf("org.settings.saml_idp_endpoint")
Dim Saml_idp_initiated_loginEnabled As Boolean = jResp.BoolOf("org.settings.saml_idp_initiated_login.enabled")
Dim Saml_idp_metadata_uploaded As Boolean = jResp.BoolOf("org.settings.saml_idp_metadata_uploaded")
Dim Saml_login_url As String = jResp.StringOf("org.settings.saml_login_url")
Dim Saml_strict_modeEnabled As Boolean = jResp.BoolOf("org.settings.saml_strict_mode.enabled")
Dim SubscriptionType As String = jResp.StringOf("org.subscription.type")
Dim Trial As Boolean = jResp.BoolOf("org.trial")
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("org.settings.saml_autocreate_users_domains.domains")
While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("org.settings.saml_autocreate_users_domains.domains[i]")
    i = i + 1
End While

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}"
    }
  ]
}