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>'
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}}/tooling/sobjects/:SOBJECT_API_NAME', @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 @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, '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 @jResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "objectDescribe": {
-- "activateable": false,
-- "associateEntityType": null,
-- "associateParentEntity": null,
-- "createable": true,
-- "custom": false,
-- "customSetting": false,
-- "deepCloneable": false,
-- "deletable": true,
-- "deprecatedAndHidden": false,
-- "feedEnabled": false,
-- "hasSubtypes": false,
-- "isInterface": false,
-- "isSubtype": false,
-- "keyPrefix": "01p",
-- "label": "Apex Class",
-- "labelPlural": "Apex Classes",
-- "layoutable": true,
-- "mergeable": false,
-- "mruEnabled": true,
-- "name": "ApexClass",
-- "queryable": true,
-- "replicateable": true,
-- "retrieveable": true,
-- "searchable": true,
-- "triggerable": false,
-- "undeletable": false,
-- "updateable": true,
-- "urls": {
-- "compactLayouts": "/services/data/v59.0/tooling/sobjects/ApexClass/describe/compactLayouts",
-- "rowTemplate": "/services/data/v59.0/tooling/sobjects/ApexClass/{ID}",
-- "describe": "/services/data/v59.0/tooling/sobjects/ApexClass/describe",
-- "layouts": "/services/data/v59.0/tooling/sobjects/ApexClass/describe/layouts",
-- "sobject": "/services/data/v59.0/tooling/sobjects/ApexClass"
-- }
-- },
-- "recentItems": [
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @Activateable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Activateable OUT, 'objectDescribe.activateable'
DECLARE @AssociateEntityType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @AssociateEntityType OUT, 'objectDescribe.associateEntityType'
DECLARE @AssociateParentEntity nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @AssociateParentEntity OUT, 'objectDescribe.associateParentEntity'
DECLARE @Createable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Createable OUT, 'objectDescribe.createable'
DECLARE @Custom int
EXEC sp_OAMethod @jResp, 'BoolOf', @Custom OUT, 'objectDescribe.custom'
DECLARE @CustomSetting int
EXEC sp_OAMethod @jResp, 'BoolOf', @CustomSetting OUT, 'objectDescribe.customSetting'
DECLARE @DeepCloneable int
EXEC sp_OAMethod @jResp, 'BoolOf', @DeepCloneable OUT, 'objectDescribe.deepCloneable'
DECLARE @Deletable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Deletable OUT, 'objectDescribe.deletable'
DECLARE @DeprecatedAndHidden int
EXEC sp_OAMethod @jResp, 'BoolOf', @DeprecatedAndHidden OUT, 'objectDescribe.deprecatedAndHidden'
DECLARE @FeedEnabled int
EXEC sp_OAMethod @jResp, 'BoolOf', @FeedEnabled OUT, 'objectDescribe.feedEnabled'
DECLARE @HasSubtypes int
EXEC sp_OAMethod @jResp, 'BoolOf', @HasSubtypes OUT, 'objectDescribe.hasSubtypes'
DECLARE @IsInterface int
EXEC sp_OAMethod @jResp, 'BoolOf', @IsInterface OUT, 'objectDescribe.isInterface'
DECLARE @IsSubtype int
EXEC sp_OAMethod @jResp, 'BoolOf', @IsSubtype OUT, 'objectDescribe.isSubtype'
DECLARE @KeyPrefix nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @KeyPrefix OUT, 'objectDescribe.keyPrefix'
DECLARE @Label nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Label OUT, 'objectDescribe.label'
DECLARE @LabelPlural nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LabelPlural OUT, 'objectDescribe.labelPlural'
DECLARE @Layoutable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Layoutable OUT, 'objectDescribe.layoutable'
DECLARE @Mergeable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Mergeable OUT, 'objectDescribe.mergeable'
DECLARE @MruEnabled int
EXEC sp_OAMethod @jResp, 'BoolOf', @MruEnabled OUT, 'objectDescribe.mruEnabled'
DECLARE @Name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'objectDescribe.name'
DECLARE @Queryable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Queryable OUT, 'objectDescribe.queryable'
DECLARE @Replicateable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Replicateable OUT, 'objectDescribe.replicateable'
DECLARE @Retrieveable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Retrieveable OUT, 'objectDescribe.retrieveable'
DECLARE @Searchable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Searchable OUT, 'objectDescribe.searchable'
DECLARE @Triggerable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Triggerable OUT, 'objectDescribe.triggerable'
DECLARE @Undeletable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Undeletable OUT, 'objectDescribe.undeletable'
DECLARE @Updateable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Updateable OUT, 'objectDescribe.updateable'
DECLARE @CompactLayouts nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CompactLayouts OUT, 'objectDescribe.urls.compactLayouts'
DECLARE @RowTemplate nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @RowTemplate OUT, 'objectDescribe.urls.rowTemplate'
DECLARE @Describe nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Describe OUT, 'objectDescribe.urls.describe'
DECLARE @Layouts nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Layouts OUT, 'objectDescribe.urls.layouts'
DECLARE @Sobject nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Sobject OUT, 'objectDescribe.urls.sobject'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'recentItems'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME
Postman Collection Item JSON
{
"name": "Get Tooling Metadata SObject",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tooling",
"sobjects",
":SOBJECT_API_NAME"
],
"variable": [
{
"key": "SOBJECT_API_NAME",
"value": ""
}
]
}
},
"response": [
{
"name": "Get Tooling Metadata SObject",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tooling",
"sobjects",
":SOBJECT_API_NAME"
],
"variable": [
{
"key": "SOBJECT_API_NAME",
"value": "ApexClass"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Mon, 11 Dec 2023 10:36:20 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"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=298/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 \"objectDescribe\": {\n \"activateable\": false,\n \"associateEntityType\": null,\n \"associateParentEntity\": null,\n \"createable\": true,\n \"custom\": false,\n \"customSetting\": false,\n \"deepCloneable\": false,\n \"deletable\": true,\n \"deprecatedAndHidden\": false,\n \"feedEnabled\": false,\n \"hasSubtypes\": false,\n \"isInterface\": false,\n \"isSubtype\": false,\n \"keyPrefix\": \"01p\",\n \"label\": \"Apex Class\",\n \"labelPlural\": \"Apex Classes\",\n \"layoutable\": true,\n \"mergeable\": false,\n \"mruEnabled\": true,\n \"name\": \"ApexClass\",\n \"queryable\": true,\n \"replicateable\": true,\n \"retrieveable\": true,\n \"searchable\": true,\n \"triggerable\": false,\n \"undeletable\": false,\n \"updateable\": true,\n \"urls\": {\n \"compactLayouts\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe/compactLayouts\",\n \"rowTemplate\": \"/services/data/v59.0/tooling/sobjects/ApexClass/{ID}\",\n \"describe\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe\",\n \"layouts\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe/layouts\",\n \"sobject\": \"/services/data/v59.0/tooling/sobjects/ApexClass\"\n }\n },\n \"recentItems\": []\n}"
}
]
}