SQL Server / CleverTap API / Get Message Reports API
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.
-- {
-- "from": "20180111",
-- "to": "20181030",
-- "daily": false,
-- "channel": [
-- "push"
-- ],
-- "delivery": [
-- "inaction",
-- "action"
-- ],
-- "status": [
-- "completed"
-- ],
-- "message_type": [
-- "single"
-- ],
-- "label": [
-- ]
-- }
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, 'from', '20180111'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'to', '20181030'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'daily', 0
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'channel[0]', 'push'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'delivery[0]', 'inaction'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'delivery[1]', 'action'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'status[0]', 'completed'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'message_type[0]', 'single'
EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'label'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-CleverTap-Passcode', '{{passcode}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-CleverTap-Account-Id', '{{id}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://api.clevertap.com/1/message/report.json', '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 "X-CleverTap-Account-Id: {{id}}"
-H "X-CleverTap-Passcode: {{passcode}}"
-H "Content-Type: application/json"
-d '{
"from":"20180111",
"to":"20181030",
"daily":false,
"channel":[
"push"
],
"delivery":[
"inaction", "action"
],
"status":[
"completed"
],
"message_type":[
"single"
],
"label":[
]
}'
https://api.clevertap.com/1/message/report.json
Postman Collection Item JSON
{
"name": "Get Message Reports API",
"request": {
"method": "POST",
"header": [
{
"key": "X-CleverTap-Account-Id",
"value": "{{id}}"
},
{
"key": "X-CleverTap-Passcode",
"value": "{{passcode}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"from\":\"20180111\",\n \"to\":\"20181030\",\n \"daily\":false,\n \"channel\":[\n \"push\"\n ],\n \"delivery\":[\n \"inaction\", \"action\"\n ],\n \"status\":[\n \"completed\"\n ],\n \"message_type\":[\n \"single\"\n ],\n \"label\":[\n ]\n}"
},
"url": {
"raw": "https://api.clevertap.com/1/message/report.json",
"protocol": "https",
"host": [
"api",
"clevertap",
"com"
],
"path": [
"1",
"message",
"report.json"
]
}
},
"response": [
]
}