SQL Server / Braze Endpoints / Canvas Data Series Analytics
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, 'canvas_id', '{{canvas_id}}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'ending_at', '2018-05-30T23:59:59-5:00'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'starting_at', '2018-05-28T23:59:59-5:00'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'include_variant_breakdown', 'true'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'include_step_breakdown', 'true'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'include_deleted_step_data', 'true'
-- 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/canvas/data_series', @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 "canvas_id=%7B%7Bcanvas_id%7D%7D"
-d "ending_at=2018-05-30T23%3A59%3A59-5%3A00"
-d "starting_at=2018-05-28T23%3A59%3A59-5%3A00"
-d "include_variant_breakdown=true"
-d "include_step_breakdown=true"
-d "include_deleted_step_data=true"
-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/canvas/data_series
Postman Collection Item JSON
{
"name": "Canvas Data Series Analytics",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{api_key}}",
"type": "text"
}
],
"url": {
"raw": "https://{{instance_url}}/canvas/data_series?canvas_id={{canvas_id}}&ending_at=2018-05-30T23:59:59-5:00&starting_at=2018-05-28T23:59:59-5:00&include_variant_breakdown=true&include_step_breakdown=true&include_deleted_step_data=true",
"protocol": "https",
"host": [
"{{instance_url}}"
],
"path": [
"canvas",
"data_series"
],
"query": [
{
"key": "canvas_id",
"value": "{{canvas_id}}",
"description": "(Required) String\n\nCanvas API Identifier"
},
{
"key": "ending_at",
"value": "2018-05-30T23:59:59-5:00",
"description": "(Required) DateTime (ISO 8601 string)\n\nDate on which the data export should end - defaults to time of the request"
},
{
"key": "starting_at",
"value": "2018-05-28T23:59:59-5:00",
"description": "(Optional) DateTime (ISO 8601 string) \n\nDate on which the data export should begin (either length or starting_at are required)"
},
{
"key": "length",
"value": "10",
"description": "(Optional) DateTime (ISO 8601 string)\n\nMax number of days before ending_at to include in the returned series - must be between 1 and 14 inclusive (either length or starting_at required)",
"disabled": true
},
{
"key": "include_variant_breakdown",
"value": "true",
"description": "(Optional) Boolean\n\nWhether or not to include variant stats (defaults to false)"
},
{
"key": "include_step_breakdown",
"value": "true",
"description": "(Optional) Boolean\n\nWhether or not to include step stats (defaults to false)"
},
{
"key": "include_deleted_step_data",
"value": "true",
"description": "(Optional) Boolean\n\nWhether or not to include step stats for deleted steps (defaults to false)"
}
]
},
"description": "This endpoint allows you to export time series data for a Canvas.\n\n### Components Used\n- [Canvas Identifier](https://www.braze.com/docs/api/identifier_types/)\n\n## Response\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n \"data\": {\n \"name\": (string) Canvas name,\n \"stats\": [\n {\n \"time\": (string) date as ISO 8601 date,\n \"total_stats\": {\n \"revenue\": (float),\n \"conversions\": (int),\n \"conversions_by_entry_time\": (int),\n \"entries\": (int)\n },\n \"variant_stats\": (optional) {\n \"00000000-0000-0000-0000-0000000000000\": (API identifier for variant) {\n \"name\": (string) name of variant,\n \"revenue\": (int),\n \"conversions\": (int),\n \"conversions_by_entry_time\": (int),\n \"entries\": (int)\n },\n ... (more variants)\n },\n \"step_stats\": (optional) {\n \"00000000-0000-0000-0000-0000000000000\": (API identifier for step) {\n \"name\": (string) name of step,\n \"revenue\": (float),\n \"conversions\": (int),\n \"conversions_by_entry_time\": (int),\n \"messages\": {\n \"email\": [\n {\n \"sent\": (int),\n \"opens\": (int),\n \"unique_opens\": (int),\n \"clicks\": (int),\n ... (more stats)\n }\n ],\n ... (more channels)\n }\n },\n ... (more steps)\n }\n },\n ... (more stats by time)\n ]\n },\n \"message\": (required, string) the status of the export, returns 'success' when completed without errors\n}\n```"
},
"response": [
]
}