Chilkat Online Tools

TCL / ForgeRock Identity Cloud Collection / Step 1: Create or update assetlinks.json

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# Use this online tool to generate code from sample JSON: Generate Code to Create JSON

# The following JSON is sent in the request body.

# [
#   {
#     "relation": [
#       "delegate_permission/common.handle_all_urls",
#       "delegate_permission/common.get_login_creds"
#     ],
#     "target": {
#       "namespace": "web",
#       "site": "https://id.mycompany.com"
#     }
#   }
# ]

set jarr [new_CkJsonArray]

CkJsonArray_AddObjectAt $jarr -1
# jsonObj_1 is a CkJsonObject
set jsonObj_1 [CkJsonArray_ObjectAt $jarr [expr [CkJsonArray_get_Size $jarr] - 1]]
CkJsonObject_UpdateString $jsonObj_1 "relation[0]" "delegate_permission/common.handle_all_urls"
CkJsonObject_UpdateString $jsonObj_1 "relation[1]" "delegate_permission/common.get_login_creds"
CkJsonObject_UpdateString $jsonObj_1 "target.namespace" "web"
CkJsonObject_UpdateString $jsonObj_1 "target.site" "https://id.mycompany.com"
delete_CkJsonObject $jsonObj_1

# Adds the "Authorization: Bearer <access_token>" header.
CkHttp_put_AuthToken $http "<access_token>"

set sbRequestBody [new_CkStringBuilder]

CkJsonArray_EmitSb $jarr $sbRequestBody

# resp is a CkHttpResponse
set resp [CkHttp_PTextSb $http "PUT" "https://id.mycompany.com/.well-known/assetlinks.json" $sbRequestBody "utf-8" "application/json" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonArray $jarr
    delete_CkStringBuilder $sbRequestBody
    exit
}

puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp


delete_CkHttp $http
delete_CkJsonArray $jarr
delete_CkStringBuilder $sbRequestBody

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-d '[
  {
    "relation": [
      "delegate_permission/common.handle_all_urls",
      "delegate_permission/common.get_login_creds"
    ],
    "target": {
      "namespace": "web",
      "site": "https://id.mycompany.com"
    }
  }
]'
https://id.mycompany.com/.well-known/assetlinks.json

Postman Collection Item JSON

{
  "name": "Step 1: Create or update assetlinks.json",
  "request": {
    "method": "PUT",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "[\n  {\n    \"relation\": [\n      \"delegate_permission/common.handle_all_urls\",\n      \"delegate_permission/common.get_login_creds\"\n    ],\n    \"target\": {\n      \"namespace\": \"web\",\n      \"site\": \"https://id.mycompany.com\"\n    }\n  }\n]",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{customDomainUrl}}/.well-known/assetlinks.json",
      "host": [
        "{{customDomainUrl}}"
      ],
      "path": [
        ".well-known",
        "assetlinks.json"
      ]
    }
  },
  "response": [
  ]
}