Chilkat Online Tools

SQL Server / Braze Endpoints / List Available Content Blocks

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'modified_after', '2020-01-01T01:01:01.000000'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'modified_before', '2020-02-01T01:01:01.000000'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 100
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'offset', 1

    -- Adds the "Authorization: Bearer {{api_key}}" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '{{api_key}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://rest.iad-01.braze.com/content_blocks/list', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams


END
GO

Curl Command

curl -G -d "modified_after=2020-01-01T01%3A01%3A01.000000"
	-d "modified_before=2020-02-01T01%3A01%3A01.000000"
	-d "limit=100"
	-d "offset=1"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/content_blocks/list

Postman Collection Item JSON

{
  "name": "List Available Content Blocks",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/content_blocks/list?modified_after=2020-01-01T01:01:01.000000&modified_before=2020-02-01T01:01:01.000000&limit=100&offset=1",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "content_blocks",
        "list"
      ],
      "query": [
        {
          "key": "modified_after",
          "value": "2020-01-01T01:01:01.000000",
          "description": "(Optional) String in ISO 8601\n\nRetrieve only content blocks updated at or after the given time."
        },
        {
          "key": "modified_before",
          "value": "2020-02-01T01:01:01.000000",
          "description": "(Optional) String in ISO 8601\n\nRetrieve only content blocks updated at or before the given time."
        },
        {
          "key": "limit",
          "value": "100",
          "description": "(Optional) Positive Number\n\nMaximum number of content blocks to retrieve, default to 100 if not provided, maximum acceptable value is 1000."
        },
        {
          "key": "offset",
          "value": "1",
          "description": "(Optional) Positive Number\n\nNumber of content blocks to skip before returning rest of the templates that fit the search criteria."
        }
      ]
    },
    "description": "This endpoint will list existing Content Block information.\n\n### Successful Response Properties\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR_REST_API_KEY\n{\n  \"count\": \"integer\",\n  \"content_blocks\": [\n    {\n      \"content_block_id\": \"string\",\n      \"name\": \"string\",\n      \"content_type\": \"html or text\",\n      \"liquid_tag\": \"string\",\n      \"inclusion_count\" : \"integer\",\n      \"created_at\": \"time-in-iso\",\n      \"last_edited\": \"time-in-iso\",\n      \"tags\" : \"array of strings\"\n    }\n  ]\n}\n```\n\n### Possible Errors\n- `Modified after time is invalid.`\nThe date you have provided is not a valid or parsable date. Please reformat this value as a string in ISO 8601 format (`yyyy-mm-ddThh:mm:ss.ffffff`).\n\n- `Modified before time is invalid.`\nThe date you have provided is not a valid or parsable date. Please reformat this value as a string in ISO 8601 format (`yyyy-mm-ddThh:mm:ss.ffffff`).\n\n- `Modified after time must be earlier than or the same as modified before time.`\n\n- `Content Block number limit is invalid.`\nThe `limit` parameter must be an integer (positive number) greater than 0.\n\n- `Content Block number limit must be greater than 0.`\nThe `limit` parameter must be an integer (positive number) greater than 0.\n\n- `Content Block number limit exceeds maximum of 1000.`\nThe `limit` parameter must be an integer (positive number) greater than 0.\n\n- `Offset is invalid.`\nThe `offset` parameter must be an integer (positive number) greater than 0.\n\n- `Offset must be greater than 0.`\nThe `offset` parameter must be an integer (positive number) greater than 0."
  },
  "response": [
  ]
}