Chilkat Online Tools

Foxpro / Salesforce Platform APIs / Get Tooling Metadata SObject

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lnActivateable
LOCAL lcAssociateEntityType
LOCAL lcAssociateParentEntity
LOCAL lnCreateable
LOCAL lnCustom
LOCAL lnCustomSetting
LOCAL lnDeepCloneable
LOCAL lnDeletable
LOCAL lnDeprecatedAndHidden
LOCAL lnFeedEnabled
LOCAL lnHasSubtypes
LOCAL lnIsInterface
LOCAL lnIsSubtype
LOCAL lcKeyPrefix
LOCAL lcLabel
LOCAL lcLabelPlural
LOCAL lnLayoutable
LOCAL lnMergeable
LOCAL lnMruEnabled
LOCAL lcName
LOCAL lnQueryable
LOCAL lnReplicateable
LOCAL lnRetrieveable
LOCAL lnSearchable
LOCAL lnTriggerable
LOCAL lnUndeletable
LOCAL lnUpdateable
LOCAL lcCompactLayouts
LOCAL lcRowTemplate
LOCAL lcDescribe
LOCAL lcLayouts
LOCAL lcSobject
LOCAL i
LOCAL lnCount_i

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://domain.com/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

* 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

lnActivateable = loJResp.BoolOf("objectDescribe.activateable")
lcAssociateEntityType = loJResp.StringOf("objectDescribe.associateEntityType")
lcAssociateParentEntity = loJResp.StringOf("objectDescribe.associateParentEntity")
lnCreateable = loJResp.BoolOf("objectDescribe.createable")
lnCustom = loJResp.BoolOf("objectDescribe.custom")
lnCustomSetting = loJResp.BoolOf("objectDescribe.customSetting")
lnDeepCloneable = loJResp.BoolOf("objectDescribe.deepCloneable")
lnDeletable = loJResp.BoolOf("objectDescribe.deletable")
lnDeprecatedAndHidden = loJResp.BoolOf("objectDescribe.deprecatedAndHidden")
lnFeedEnabled = loJResp.BoolOf("objectDescribe.feedEnabled")
lnHasSubtypes = loJResp.BoolOf("objectDescribe.hasSubtypes")
lnIsInterface = loJResp.BoolOf("objectDescribe.isInterface")
lnIsSubtype = loJResp.BoolOf("objectDescribe.isSubtype")
lcKeyPrefix = loJResp.StringOf("objectDescribe.keyPrefix")
lcLabel = loJResp.StringOf("objectDescribe.label")
lcLabelPlural = loJResp.StringOf("objectDescribe.labelPlural")
lnLayoutable = loJResp.BoolOf("objectDescribe.layoutable")
lnMergeable = loJResp.BoolOf("objectDescribe.mergeable")
lnMruEnabled = loJResp.BoolOf("objectDescribe.mruEnabled")
lcName = loJResp.StringOf("objectDescribe.name")
lnQueryable = loJResp.BoolOf("objectDescribe.queryable")
lnReplicateable = loJResp.BoolOf("objectDescribe.replicateable")
lnRetrieveable = loJResp.BoolOf("objectDescribe.retrieveable")
lnSearchable = loJResp.BoolOf("objectDescribe.searchable")
lnTriggerable = loJResp.BoolOf("objectDescribe.triggerable")
lnUndeletable = loJResp.BoolOf("objectDescribe.undeletable")
lnUpdateable = loJResp.BoolOf("objectDescribe.updateable")
lcCompactLayouts = loJResp.StringOf("objectDescribe.urls.compactLayouts")
lcRowTemplate = loJResp.StringOf("objectDescribe.urls.rowTemplate")
lcDescribe = loJResp.StringOf("objectDescribe.urls.describe")
lcLayouts = loJResp.StringOf("objectDescribe.urls.layouts")
lcSobject = loJResp.StringOf("objectDescribe.urls.sobject")
i = 0
lnCount_i = loJResp.SizeOfArray("recentItems")
DO WHILE i < lnCount_i
    loJResp.I = i
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

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}"
    }
  ]
}