Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; 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
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"billing.type","parent_billing")
CkJsonObject::ckUpdateString(json,"created","2019-09-26T17:28:28Z")
CkJsonObject::ckUpdateString(json,"description","some description")
CkJsonObject::ckUpdateString(json,"name","New child org")
CkJsonObject::ckUpdateString(json,"public_id","abcdef12345")
CkJsonObject::ckUpdateBool(json,"settings.private_widget_share",0)
CkJsonObject::ckUpdateBool(json,"settings.saml.enabled",0)
CkJsonObject::ckUpdateString(json,"settings.saml_autocreate_access_role","ro")
CkJsonObject::ckUpdateString(json,"settings.saml_autocreate_users_domains.domains[0]","example.com")
CkJsonObject::ckUpdateString(json,"settings.saml_autocreate_users_domains.domains[1]","example.com")
CkJsonObject::ckUpdateBool(json,"settings.saml_autocreate_users_domains.enabled",0)
CkJsonObject::ckUpdateBool(json,"settings.saml_can_be_enabled",0)
CkJsonObject::ckUpdateString(json,"settings.saml_idp_endpoint","https://my.saml.endpoint")
CkJsonObject::ckUpdateBool(json,"settings.saml_idp_initiated_login.enabled",0)
CkJsonObject::ckUpdateBool(json,"settings.saml_idp_metadata_uploaded",0)
CkJsonObject::ckUpdateString(json,"settings.saml_login_url","https://my.saml.login.url")
CkJsonObject::ckUpdateBool(json,"settings.saml_strict_mode.enabled",0)
CkJsonObject::ckUpdateString(json,"subscription.type","pro")
CkJsonObject::ckUpdateBool(json,"trial",0)
CkHttp::ckSetRequestHeader(http,"Content-Type","application/json")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
sbRequestBody.i = CkStringBuilder::ckCreate()
If sbRequestBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckEmitSb(json,sbRequestBody)
resp.i = CkHttp::ckPTextSb(http,"PUT","https://api.app.ddog-gov.com/api/v1/org/:public_id",sbRequestBody,"utf-8","application/json",0,0)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
ProcedureReturn
EndIf
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpResponse::ckGetBodySb(resp,sbResponseBody)
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttpResponse::ckHeader(resp)
Debug "Failed."
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
CkHttpResponse::ckDispose(resp)
; 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
strVal.s
v_Type.s = CkJsonObject::ckStringOf(jResp,"org.billing.type")
Created.s = CkJsonObject::ckStringOf(jResp,"org.created")
Description.s = CkJsonObject::ckStringOf(jResp,"org.description")
Name.s = CkJsonObject::ckStringOf(jResp,"org.name")
Public_id.s = CkJsonObject::ckStringOf(jResp,"org.public_id")
Private_widget_share.i = CkJsonObject::ckBoolOf(jResp,"org.settings.private_widget_share")
Enabled.i = CkJsonObject::ckBoolOf(jResp,"org.settings.saml.enabled")
Saml_autocreate_access_role.s = CkJsonObject::ckStringOf(jResp,"org.settings.saml_autocreate_access_role")
Saml_autocreate_users_domainsEnabled.i = CkJsonObject::ckBoolOf(jResp,"org.settings.saml_autocreate_users_domains.enabled")
Saml_can_be_enabled.i = CkJsonObject::ckBoolOf(jResp,"org.settings.saml_can_be_enabled")
Saml_idp_endpoint.s = CkJsonObject::ckStringOf(jResp,"org.settings.saml_idp_endpoint")
Saml_idp_initiated_loginEnabled.i = CkJsonObject::ckBoolOf(jResp,"org.settings.saml_idp_initiated_login.enabled")
Saml_idp_metadata_uploaded.i = CkJsonObject::ckBoolOf(jResp,"org.settings.saml_idp_metadata_uploaded")
Saml_login_url.s = CkJsonObject::ckStringOf(jResp,"org.settings.saml_login_url")
Saml_strict_modeEnabled.i = CkJsonObject::ckBoolOf(jResp,"org.settings.saml_strict_mode.enabled")
SubscriptionType.s = CkJsonObject::ckStringOf(jResp,"org.subscription.type")
Trial.i = CkJsonObject::ckBoolOf(jResp,"org.trial")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"org.settings.saml_autocreate_users_domains.domains")
While i < count_i
CkJsonObject::setCkI(jResp, i)
strVal = CkJsonObject::ckStringOf(jResp,"org.settings.saml_autocreate_users_domains.domains[i]")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
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}"
}
]
}