SQL Server / Braze Endpoints / Update Scheduled Messages
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
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "schedule_id": "schedule_identifier",
-- "schedule": {
-- "time": "2017-05-24T20:30:36Z"
-- },
-- "messages": {
-- "apple_push": {
-- "alert": "Updated Message!",
-- "badge": 1
-- },
-- "android_push": {
-- "title": "Updated title!",
-- "alert": "Updated message!"
-- },
-- "sms": {
-- "subscription_group_id": "subscription_group_identifier",
-- "message_variation_id": "message_variation_identifier",
-- "body": "This is my SMS body.",
-- "app_id": "app_identifier"
-- }
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'schedule_id', 'schedule_identifier'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'schedule.time', '2017-05-24T20:30:36Z'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.apple_push.alert', 'Updated Message!'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'messages.apple_push.badge', 1
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.android_push.title', 'Updated title!'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.android_push.alert', 'Updated message!'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.sms.subscription_group_id', 'subscription_group_identifier'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.sms.message_variation_id', 'message_variation_identifier'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.sms.body', 'This is my SMS body.'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'messages.sms.app_id', 'app_identifier'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
-- Adds the "Authorization: Bearer {{api_key}}" header.
EXEC sp_OASetProperty @http, 'AuthToken', '{{api_key}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://rest.iad-01.braze.com/messages/schedule/update', 'application/json', @json
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 @json
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 @json
END
GO
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer {{api_key}}"
-d '{
"schedule_id": "schedule_identifier",
"schedule": {
"time": "2017-05-24T20:30:36Z"
},
"messages": {
"apple_push": {
"alert": "Updated Message!",
"badge": 1
},
"android_push": {
"title": "Updated title!",
"alert": "Updated message!"
},
"sms": {
"subscription_group_id": "subscription_group_identifier",
"message_variation_id": "message_variation_identifier",
"body": "This is my SMS body.",
"app_id": "app_identifier"
}
}
}'
https://rest.iad-01.braze.com/messages/schedule/update
Postman Collection Item JSON
{
"name": "Update Scheduled Messages",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{api_key}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"schedule_id\": \"schedule_identifier\",\n \"schedule\": {\n \"time\": \"2017-05-24T20:30:36Z\"\n },\n \"messages\": {\n \"apple_push\": {\n \"alert\": \"Updated Message!\",\n \"badge\": 1\n },\n \"android_push\": {\n \"title\": \"Updated title!\",\n \"alert\": \"Updated message!\"\n },\n \"sms\": { \n \t\"subscription_group_id\": \"subscription_group_identifier\",\n \t\"message_variation_id\": \"message_variation_identifier\",\n \t\"body\": \"This is my SMS body.\",\n \t\"app_id\": \"app_identifier\"\n }\n }\n}"
},
"url": {
"raw": "https://{{instance_url}}/messages/schedule/update",
"protocol": "https",
"host": [
"{{instance_url}}"
],
"path": [
"messages",
"schedule",
"update"
]
},
"description": "The messages update schedule endpoint accepts updates to either the `schedule` or `messages` parameter or both. Your request must contain at least one of those two keys.\n\n### Request Parameters\n| Parameter | Required | Data Type | Description |\n| --------- | ---------| --------- | ----------- |\n|`schedule_id`|Required|String| The schedule_id to update (obtained from the response to create schedule)|\n|`schedule` | Optional | Object | See schedule object |\n|`messages` | Optional | Object | See available message object |\n\n## Request Components\n\n- [Schedule Object](https://www.braze.com/docs/api/objects_filters/schedule_object/)\n\n### Available Messaging Objects\n\n- [Android Objects](https://www.braze.com/docs/api/objects_filters/android_objects/)\n- [Apple Objects](https://www.braze.com/docs/api/objects_filters/apple_objects/)\n- [Content Cards Object](https://www.braze.com/docs/api/objects_filters/content_cards_object/)\n- [Email Object](https://www.braze.com/docs/api/objects_filters/email_object/)\n- [Kindle or FireOS Object](https://www.braze.com/docs/api/objects_filters/kindle_and_fireos_object/)\n- [SMS Object](https://www.braze.com/docs/api/objects_filters/sms_object/)\n- [Web Objects](https://www.braze.com/docs/api/objects_filters/web_objects/)\n- [Webhook Object](https://www.braze.com/docs/api/objects_filters/webhook_objects/)\n- [Windows Objects](https://www.braze.com/docs/api/objects_filters/windows_objects/)"
},
"response": [
]
}