Chilkat Online Tools

TCL / Braze Endpoints / Update Content Block

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.

# {
#   "content_block_id": "content_block_id",
#   "name": "content_block",
#   "description": "This is my content block",
#   "content": "HTML or text content within block",
#   "state": "draft",
#   "tags": [
#     "marketing"
#   ]
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "content_block_id" "content_block_id"
CkJsonObject_UpdateString $json "name" "content_block"
CkJsonObject_UpdateString $json "description" "This is my content block"
CkJsonObject_UpdateString $json "content" "HTML or text content within block"
CkJsonObject_UpdateString $json "state" "draft"
CkJsonObject_UpdateString $json "tags[0]" "marketing"

CkHttp_SetRequestHeader $http "Content-Type" "application/json"
# Adds the "Authorization: Bearer {{api_key}}" header.
CkHttp_put_AuthToken $http "{{api_key}}"

# resp is a CkHttpResponse
set resp [CkHttp_PostJson3 $http "https://rest.iad-01.braze.com/content_blocks/update" "application/json" $json]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    exit
}

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


delete_CkHttp $http
delete_CkJsonObject $json

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "Authorization: Bearer {{api_key}}"
	-d '{
  "content_block_id" :"content_block_id", 
  "name": "content_block",
  "description": "This is my content block",
  "content": "HTML or text content within block",
  "state": "draft",
  "tags": ["marketing"]
}'
https://rest.iad-01.braze.com/content_blocks/update

Postman Collection Item JSON

{
  "name": "Update Content Block",
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"content_block_id\" :\"content_block_id\", \n  \"name\": \"content_block\",\n  \"description\": \"This is my content block\",\n  \"content\": \"HTML or text content within block\",\n  \"state\": \"draft\",\n  \"tags\": [\"marketing\"]\n}"
    },
    "url": {
      "raw": "https://{{instance_url}}/content_blocks/update",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "content_blocks",
        "update"
      ]
    },
    "description": "### Request Parameters\n| Parameter | Required | Data Type | Description |\n|---|---|---|---|\n|`content_block_id`|\tYes |\tString |\tYour Content Block's API Identifier.|\n| `name` | Yes | String | Can only be provided when the content block is in a draft state. Must be less than 100 characters. |\n| `description` | No | String | The description of the content block. Must be less than 250 characters. |\n| `content` | Yes | String | HTML or text content within Content Block.\n| `state` | Optional | \"active\" or \"draft\" | Choose \"active\" or \"draft\". Defaults to `active` if not specified. Can not set an active content block to draft. |\n| `tags` | No | Array of Strings. | Tags must already exist. |\n\n### Successful Response Properties\n\n```json\n{\n  \"content_block_id\": \"newly-generated-block-id\",\n  \"liquid_tag\": \"generated-block-tag-from-content_block_name\",\n  \"created_at\": \"time-created-in-iso\",\n  \"message\": \"success\"\n}\n```\n\n### Possible Errors\n- `Content cannot be blank.`\n\n- `Content must be a string.`\n\n- `Content must be smaller than 50kb.`\nThe content in your content block must be less than 50kb total.\n\n- `Content contains malformed liquid.`\nThe liquid provided is not valid or parsable. Please try again or reach out to support.\n\n- `Content Block cannot be referenced within itself.`\n\n- `Content Block description cannot be blank.`\n\n- `Content Block description must be a string.`\n\n- `Content block description must be shorter than 250 characters.`\nYour content block description must be less than 250 characters.\n\n- `Content Block name cannot be blank.`\n\n- `Content Block name must be a shorter than 100 characters.`\n\n- `Content Block name can only contain alphanumeric characters.`\nContent Block names can include any of the following characters: the letters (capitalized or lowercase) `A` through `Z`, the numbers `0` through `9`, dashes `-`, and underscores `_`. It cannot contain non-alphanumeric characters like emojis, `!`, `@`, `~`, `&`, and other \"special\" characters.\n\n- `Content Block with this name already exists.`\n\n- `Content Block name cannot be updated for active Content Blocks.`\n\n- `Content Block state must be either Active or Draft.`\n\n- `Active Content Block can not be updated to Draft. Please create a new Content Block.`\n\n- `Tags must be an array.`\n\n- `All Tags must be Strings.`\n\n- `Some Tags could not be found.`"
  },
  "response": [
  ]
}