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
-- 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
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://domain.com/services/data/v{{version}}/tabs', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jarrResp int
-- Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarrResp OUT
EXEC sp_OAMethod @jarrResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jarrResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jarrResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jarrResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- [
-- {
-- "colors": [
-- {
-- "color": "5867E8",
-- "context": "primary",
-- "theme": "theme4"
-- },
-- {
-- "color": "236FBD",
-- "context": "primary",
-- "theme": "theme3"
-- }
-- ],
-- "custom": false,
-- "iconUrl": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts32.png",
-- "icons": [
-- {
-- "contentType": "image/png",
-- "height": 32,
-- "theme": "theme3",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts32.png",
-- "width": 32
-- },
-- {
-- "contentType": "image/png",
-- "height": 16,
-- "theme": "theme3",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts16.png",
-- "width": 16
-- },
-- {
-- "contentType": "image/svg+xml",
-- "height": 0,
-- "theme": "theme4",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/account.svg",
-- "width": 0
-- },
-- {
-- "contentType": "image/png",
-- "height": 60,
-- "theme": "theme4",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/account_60.png",
-- "width": 60
-- },
-- {
-- "contentType": "image/png",
-- "height": 120,
-- "theme": "theme4",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/account_120.png",
-- "width": 120
-- }
-- ],
-- "label": "Accounts",
-- "miniIconUrl": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts16.png",
-- "name": "standard-Account",
-- "sobjectName": "Account",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/001/o"
-- },
-- {
-- "colors": [
-- {
-- "color": "056764",
-- "context": "primary",
-- "theme": "theme4"
-- },
-- {
-- "color": "056764",
-- "context": "primary",
-- "theme": "theme3"
-- }
-- ],
-- "custom": false,
-- "iconUrl": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench32.png",
-- "icons": [
-- {
-- "contentType": "image/png",
-- "height": 32,
-- "theme": "theme3",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench32.png",
-- "width": 32
-- },
-- {
-- "contentType": "image/png",
-- "height": 16,
-- "theme": "theme3",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench16.png",
-- "width": 16
-- }
-- ],
-- "label": "Active Scratch Orgs",
-- "miniIconUrl": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench16.png",
-- "name": "standard-ActiveScratchOrg",
-- "sobjectName": "ActiveScratchOrg",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/2AS/o"
-- },
-- {
-- "colors": [
-- {
-- "color": "06A59A",
-- "context": "primary",
-- "theme": "theme4"
-- },
-- {
-- "color": "A55647",
-- "context": "primary",
-- "theme": "theme3"
-- }
-- ],
-- "custom": false,
-- "iconUrl": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports32.png",
-- "icons": [
-- {
-- "contentType": "image/png",
-- "height": 32,
-- "theme": "theme3",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports32.png",
-- "width": 32
-- },
-- {
-- "contentType": "image/png",
-- "height": 16,
-- "theme": "theme3",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports16.png",
-- "width": 16
-- },
-- {
-- "contentType": "image/svg+xml",
-- "height": 0,
-- "theme": "theme4",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/report.svg",
-- "width": 0
-- },
-- {
-- "contentType": "image/png",
-- "height": 60,
-- "theme": "theme4",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/report_60.png",
-- "width": 60
-- },
-- {
-- "contentType": "image/png",
-- "height": 120,
-- "theme": "theme4",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/report_120.png",
-- "width": 120
-- }
-- ],
-- "label": "Reports",
-- "miniIconUrl": "https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports16.png",
-- "name": "standard-report",
-- "sobjectName": "Report",
-- "url": "https://nto-df17-demo-dev-ed.my.salesforce.com/00O/o"
-- }
-- ]
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @json int
DECLARE @custom int
DECLARE @iconUrl nvarchar(4000)
DECLARE @label nvarchar(4000)
DECLARE @miniIconUrl nvarchar(4000)
DECLARE @name nvarchar(4000)
DECLARE @sobjectName nvarchar(4000)
DECLARE @url nvarchar(4000)
DECLARE @j int
DECLARE @count_j int
DECLARE @color nvarchar(4000)
DECLARE @context nvarchar(4000)
DECLARE @theme nvarchar(4000)
DECLARE @contentType nvarchar(4000)
DECLARE @height int
DECLARE @width int
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAGetProperty @jarrResp, 'Size', @count_i OUT
WHILE @i < @count_i
BEGIN
EXEC sp_OAMethod @jarrResp, 'ObjectAt', @json OUT, @i
EXEC sp_OAMethod @json, 'BoolOf', @custom OUT, 'custom'
EXEC sp_OAMethod @json, 'StringOf', @iconUrl OUT, 'iconUrl'
EXEC sp_OAMethod @json, 'StringOf', @label OUT, 'label'
EXEC sp_OAMethod @json, 'StringOf', @miniIconUrl OUT, 'miniIconUrl'
EXEC sp_OAMethod @json, 'StringOf', @name OUT, 'name'
EXEC sp_OAMethod @json, 'StringOf', @sobjectName OUT, 'sobjectName'
EXEC sp_OAMethod @json, 'StringOf', @url OUT, 'url'
SELECT @j = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'colors'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @json, 'J', @j
EXEC sp_OAMethod @json, 'StringOf', @color OUT, 'colors[j].color'
EXEC sp_OAMethod @json, 'StringOf', @context OUT, 'colors[j].context'
EXEC sp_OAMethod @json, 'StringOf', @theme OUT, 'colors[j].theme'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'icons'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @json, 'J', @j
EXEC sp_OAMethod @json, 'StringOf', @contentType OUT, 'icons[j].contentType'
EXEC sp_OAMethod @json, 'IntOf', @height OUT, 'icons[j].height'
EXEC sp_OAMethod @json, 'StringOf', @theme OUT, 'icons[j].theme'
EXEC sp_OAMethod @json, 'StringOf', @url OUT, 'icons[j].url'
EXEC sp_OAMethod @json, 'IntOf', @width OUT, 'icons[j].width'
SELECT @j = @j + 1
END
EXEC @hr = sp_OADestroy @json
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jarrResp
END
GO
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
https://domain.com/services/data/v{{version}}/tabs
Postman Collection Item JSON
{
"name": "Tabs",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tabs",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tabs"
]
},
"description": "f a survey field can be translated or is already translated into a particular language, you can add or change the translated value of the survey field.\n\nhttps://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/request_survey_translate_add_change.htm"
},
"response": [
{
"name": "Tabs",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tabs",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tabs"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 27 Sep 2023 15:29:05 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Sforce-Limit-Info",
"value": "api-usage=6/15000"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "[\n {\n \"colors\": [\n {\n \"color\": \"5867E8\",\n \"context\": \"primary\",\n \"theme\": \"theme4\"\n },\n {\n \"color\": \"236FBD\",\n \"context\": \"primary\",\n \"theme\": \"theme3\"\n }\n ],\n \"custom\": false,\n \"iconUrl\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts32.png\",\n \"icons\": [\n {\n \"contentType\": \"image/png\",\n \"height\": 32,\n \"theme\": \"theme3\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts32.png\",\n \"width\": 32\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 16,\n \"theme\": \"theme3\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts16.png\",\n \"width\": 16\n },\n {\n \"contentType\": \"image/svg+xml\",\n \"height\": 0,\n \"theme\": \"theme4\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/account.svg\",\n \"width\": 0\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 60,\n \"theme\": \"theme4\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/account_60.png\",\n \"width\": 60\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 120,\n \"theme\": \"theme4\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/account_120.png\",\n \"width\": 120\n }\n ],\n \"label\": \"Accounts\",\n \"miniIconUrl\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/accounts16.png\",\n \"name\": \"standard-Account\",\n \"sobjectName\": \"Account\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/001/o\"\n },\n {\n \"colors\": [\n {\n \"color\": \"056764\",\n \"context\": \"primary\",\n \"theme\": \"theme4\"\n },\n {\n \"color\": \"056764\",\n \"context\": \"primary\",\n \"theme\": \"theme3\"\n }\n ],\n \"custom\": false,\n \"iconUrl\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench32.png\",\n \"icons\": [\n {\n \"contentType\": \"image/png\",\n \"height\": 32,\n \"theme\": \"theme3\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench32.png\",\n \"width\": 32\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 16,\n \"theme\": \"theme3\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench16.png\",\n \"width\": 16\n }\n ],\n \"label\": \"Active Scratch Orgs\",\n \"miniIconUrl\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/wrench16.png\",\n \"name\": \"standard-ActiveScratchOrg\",\n \"sobjectName\": \"ActiveScratchOrg\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/2AS/o\"\n },\n {\n \"colors\": [\n {\n \"color\": \"06A59A\",\n \"context\": \"primary\",\n \"theme\": \"theme4\"\n },\n {\n \"color\": \"A55647\",\n \"context\": \"primary\",\n \"theme\": \"theme3\"\n }\n ],\n \"custom\": false,\n \"iconUrl\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports32.png\",\n \"icons\": [\n {\n \"contentType\": \"image/png\",\n \"height\": 32,\n \"theme\": \"theme3\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports32.png\",\n \"width\": 32\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 16,\n \"theme\": \"theme3\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports16.png\",\n \"width\": 16\n },\n {\n \"contentType\": \"image/svg+xml\",\n \"height\": 0,\n \"theme\": \"theme4\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/report.svg\",\n \"width\": 0\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 60,\n \"theme\": \"theme4\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/report_60.png\",\n \"width\": 60\n },\n {\n \"contentType\": \"image/png\",\n \"height\": 120,\n \"theme\": \"theme4\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/t4v35/standard/report_120.png\",\n \"width\": 120\n }\n ],\n \"label\": \"Reports\",\n \"miniIconUrl\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/img/icon/reports16.png\",\n \"name\": \"standard-report\",\n \"sobjectName\": \"Report\",\n \"url\": \"https://nto-df17-demo-dev-ed.my.salesforce.com/00O/o\"\n }\n]"
}
]
}