Chilkat Online Tools

SQL Server / Salesforce Platform APIs / Resources by Version

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}}/', @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)

    -- {
    --   "tooling": "/services/data/v58.0/tooling",
    --   "metadata": "/services/data/v58.0/metadata",
    --   "eclair": "/services/data/v58.0/eclair",
    --   "folders": "/services/data/v58.0/folders",
    --   "prechatForms": "/services/data/v58.0/prechatForms",
    --   "contact-tracing": "/services/data/v58.0/contact-tracing",
    --   "jsonxform": "/services/data/v58.0/jsonxform",
    --   "chatter": "/services/data/v58.0/chatter",
    --   "payments": "/services/data/v58.0/payments",
    --   "tabs": "/services/data/v58.0/tabs",
    --   "appMenu": "/services/data/v58.0/appMenu",
    --   "quickActions": "/services/data/v58.0/quickActions",
    --   "queryAll": "/services/data/v58.0/queryAll",
    --   "commerce": "/services/data/v58.0/commerce",
    --   "wave": "/services/data/v58.0/wave",
    --   "iot": "/services/data/v58.0/iot",
    --   "analytics": "/services/data/v58.0/analytics",
    --   "search": "/services/data/v58.0/search",
    --   "smartdatadiscovery": "/services/data/v58.0/smartdatadiscovery",
    --   "identity": "https://login.salesforce.com/id/00DB0000000DFgjMAG/005B0000003TOI6IAO",
    --   "composite": "/services/data/v58.0/composite",
    --   "parameterizedSearch": "/services/data/v58.0/parameterizedSearch",
    --   "fingerprint": "/services/data/v58.0/fingerprint",
    --   "theme": "/services/data/v58.0/theme",
    --   "nouns": "/services/data/v58.0/nouns",
    --   "domino": "/services/data/v58.0/domino",
    --   "event": "/services/data/v58.0/event",
    --   "serviceTemplates": "/services/data/v58.0/serviceTemplates",
    --   "recent": "/services/data/v58.0/recent",
    --   "connect": "/services/data/v58.0/connect",
    --   "licensing": "/services/data/v58.0/licensing",
    --   "limits": "/services/data/v58.0/limits",
    --   "process": "/services/data/v58.0/process",
    --   "dedupe": "/services/data/v58.0/dedupe",
    --   "async-queries": "/services/data/v58.0/async-queries",
    --   "query": "/services/data/v58.0/query",
    --   "jobs": "/services/data/v58.0/jobs",
    --   "match": "/services/data/v58.0/match",
    --   "localizedvalue": "/services/data/v58.0/localizedvalue",
    --   "mobile": "/services/data/v58.0/mobile",
    --   "emailConnect": "/services/data/v58.0/emailConnect",
    --   "consent": "/services/data/v58.0/consent",
    --   "tokenizer": "/services/data/v58.0/tokenizer",
    --   "compactLayouts": "/services/data/v58.0/compactLayouts",
    --   "knowledgeManagement": "/services/data/v58.0/knowledgeManagement",
    --   "sobjects": "/services/data/v58.0/sobjects",
    --   "actions": "/services/data/v58.0/actions",
    --   "support": "/services/data/v58.0/support"
    -- }

    -- Sample code for parsing the JSON response...
    -- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    DECLARE @tooling nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @tooling OUT, 'tooling'
    DECLARE @metadata nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @metadata OUT, 'metadata'
    DECLARE @eclair nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @eclair OUT, 'eclair'
    DECLARE @folders nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @folders OUT, 'folders'
    DECLARE @prechatForms nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @prechatForms OUT, 'prechatForms'
    DECLARE @contact_tracing nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @contact_tracing OUT, 'contact-tracing'
    DECLARE @jsonxform nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @jsonxform OUT, 'jsonxform'
    DECLARE @chatter nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @chatter OUT, 'chatter'
    DECLARE @payments nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @payments OUT, 'payments'
    DECLARE @tabs nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @tabs OUT, 'tabs'
    DECLARE @appMenu nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @appMenu OUT, 'appMenu'
    DECLARE @quickActions nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @quickActions OUT, 'quickActions'
    DECLARE @queryAll nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @queryAll OUT, 'queryAll'
    DECLARE @commerce nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @commerce OUT, 'commerce'
    DECLARE @wave nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @wave OUT, 'wave'
    DECLARE @iot nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @iot OUT, 'iot'
    DECLARE @analytics nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @analytics OUT, 'analytics'
    DECLARE @search nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @search OUT, 'search'
    DECLARE @smartdatadiscovery nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @smartdatadiscovery OUT, 'smartdatadiscovery'
    DECLARE @identity nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @identity OUT, 'identity'
    DECLARE @composite nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @composite OUT, 'composite'
    DECLARE @parameterizedSearch nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @parameterizedSearch OUT, 'parameterizedSearch'
    DECLARE @fingerprint nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @fingerprint OUT, 'fingerprint'
    DECLARE @theme nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @theme OUT, 'theme'
    DECLARE @nouns nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @nouns OUT, 'nouns'
    DECLARE @domino nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @domino OUT, 'domino'
    DECLARE @v_event nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_event OUT, 'event'
    DECLARE @serviceTemplates nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @serviceTemplates OUT, 'serviceTemplates'
    DECLARE @recent nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @recent OUT, 'recent'
    DECLARE @connect nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @connect OUT, 'connect'
    DECLARE @licensing nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @licensing OUT, 'licensing'
    DECLARE @limits nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @limits OUT, 'limits'
    DECLARE @process nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @process OUT, 'process'
    DECLARE @dedupe nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @dedupe OUT, 'dedupe'
    DECLARE @async_queries nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @async_queries OUT, 'async-queries'
    DECLARE @query nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @query OUT, 'query'
    DECLARE @jobs nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @jobs OUT, 'jobs'
    DECLARE @match nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @match OUT, 'match'
    DECLARE @localizedvalue nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @localizedvalue OUT, 'localizedvalue'
    DECLARE @mobile nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @mobile OUT, 'mobile'
    DECLARE @emailConnect nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @emailConnect OUT, 'emailConnect'
    DECLARE @consent nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @consent OUT, 'consent'
    DECLARE @tokenizer nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @tokenizer OUT, 'tokenizer'
    DECLARE @compactLayouts nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @compactLayouts OUT, 'compactLayouts'
    DECLARE @knowledgeManagement nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @knowledgeManagement OUT, 'knowledgeManagement'
    DECLARE @sobjects nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @sobjects OUT, 'sobjects'
    DECLARE @actions nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @actions OUT, 'actions'
    DECLARE @support nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @support OUT, 'support'

    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>"
	-H "Content-Type: application/json"
https://domain.com/services/data/v{{version}}/

Postman Collection Item JSON

{
  "name": "Resources by Version",
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": ""
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        ""
      ]
    },
    "description": "Lists available resources for the specified API version, including resource name and URI."
  },
  "response": [
    {
      "name": "Resources by Version",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": ""
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            ""
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Tue, 26 Sep 2023 13:29:43 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=3/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    \"tooling\": \"/services/data/v58.0/tooling\",\n    \"metadata\": \"/services/data/v58.0/metadata\",\n    \"eclair\": \"/services/data/v58.0/eclair\",\n    \"folders\": \"/services/data/v58.0/folders\",\n    \"prechatForms\": \"/services/data/v58.0/prechatForms\",\n    \"contact-tracing\": \"/services/data/v58.0/contact-tracing\",\n    \"jsonxform\": \"/services/data/v58.0/jsonxform\",\n    \"chatter\": \"/services/data/v58.0/chatter\",\n    \"payments\": \"/services/data/v58.0/payments\",\n    \"tabs\": \"/services/data/v58.0/tabs\",\n    \"appMenu\": \"/services/data/v58.0/appMenu\",\n    \"quickActions\": \"/services/data/v58.0/quickActions\",\n    \"queryAll\": \"/services/data/v58.0/queryAll\",\n    \"commerce\": \"/services/data/v58.0/commerce\",\n    \"wave\": \"/services/data/v58.0/wave\",\n    \"iot\": \"/services/data/v58.0/iot\",\n    \"analytics\": \"/services/data/v58.0/analytics\",\n    \"search\": \"/services/data/v58.0/search\",\n    \"smartdatadiscovery\": \"/services/data/v58.0/smartdatadiscovery\",\n    \"identity\": \"https://login.salesforce.com/id/00DB0000000DFgjMAG/005B0000003TOI6IAO\",\n    \"composite\": \"/services/data/v58.0/composite\",\n    \"parameterizedSearch\": \"/services/data/v58.0/parameterizedSearch\",\n    \"fingerprint\": \"/services/data/v58.0/fingerprint\",\n    \"theme\": \"/services/data/v58.0/theme\",\n    \"nouns\": \"/services/data/v58.0/nouns\",\n    \"domino\": \"/services/data/v58.0/domino\",\n    \"event\": \"/services/data/v58.0/event\",\n    \"serviceTemplates\": \"/services/data/v58.0/serviceTemplates\",\n    \"recent\": \"/services/data/v58.0/recent\",\n    \"connect\": \"/services/data/v58.0/connect\",\n    \"licensing\": \"/services/data/v58.0/licensing\",\n    \"limits\": \"/services/data/v58.0/limits\",\n    \"process\": \"/services/data/v58.0/process\",\n    \"dedupe\": \"/services/data/v58.0/dedupe\",\n    \"async-queries\": \"/services/data/v58.0/async-queries\",\n    \"query\": \"/services/data/v58.0/query\",\n    \"jobs\": \"/services/data/v58.0/jobs\",\n    \"match\": \"/services/data/v58.0/match\",\n    \"localizedvalue\": \"/services/data/v58.0/localizedvalue\",\n    \"mobile\": \"/services/data/v58.0/mobile\",\n    \"emailConnect\": \"/services/data/v58.0/emailConnect\",\n    \"consent\": \"/services/data/v58.0/consent\",\n    \"tokenizer\": \"/services/data/v58.0/tokenizer\",\n    \"compactLayouts\": \"/services/data/v58.0/compactLayouts\",\n    \"knowledgeManagement\": \"/services/data/v58.0/knowledgeManagement\",\n    \"sobjects\": \"/services/data/v58.0/sobjects\",\n    \"actions\": \"/services/data/v58.0/actions\",\n    \"support\": \"/services/data/v58.0/support\"\n}"
    }
  ]
}