Chilkat Online Tools

SQL Server / Salesforce Platform APIs / Get All Navigation Items

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://domain.com/services/data/v{{version}}/ui-api/nav-items', @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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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)

    -- {
    --   "currentPageUrl": "/services/data/v58.0/ui-api/nav-items?formFactor=Small&page=1&pageSize=5",
    --   "eTag": "425dfe9232c5bd0e9c6e4b94771c91b8",
    --   "navItems": [
    --     {
    --       "availableInClassic": true,
    --       "availableInLightning": true,
    --       "color": null,
    --       "content": "https://pozil-dev-ed.my.salesforce.com/4nK/o",
    --       "custom": false,
    --       "developerName": "standard-AssetStatePeriod",
    --       "iconUrl": null,
    --       "id": null,
    --       "itemType": "Entity",
    --       "label": "Asset State Periods",
    --       "objectApiName": "AssetStatePeriod",
    --       "objectLabel": "Asset State Period",
    --       "objectLabelPlural": "Asset State Periods",
    --       "pageReference": {
    --         "attributes": {
    --           "objectApiName": "AssetStatePeriod",
    --           "actionName": "home"
    --         },
    --         "state": {},
    --         "type": "standard__objectPage"
    --       },
    --       "standardType": null
    --     },
    --     {
    --       "availableInClassic": true,
    --       "availableInLightning": true,
    --       "color": null,
    --       "content": "https://pozil-dev-ed.my.salesforce.com/02i/o",
    --       "custom": false,
    --       "developerName": "standard-Asset",
    --       "iconUrl": null,
    --       "id": null,
    --       "itemType": "Entity",
    --       "label": "Assets",
    --       "objectApiName": "Asset",
    --       "objectLabel": "Asset",
    --       "objectLabelPlural": "Assets",
    --       "pageReference": {
    --         "attributes": {
    --           "objectApiName": "Asset",
    --           "actionName": "home"
    --         },
    --         "state": {},
    --         "type": "standard__objectPage"
    --       },
    --       "standardType": null
    --     },
    --     {
    --       "availableInClassic": true,
    --       "availableInLightning": true,
    --       "color": null,
    --       "content": "https://pozil-dev-ed.my.salesforce.com/0cI/o",
    --       "custom": false,
    --       "developerName": "standard-AuthorizationForm",
    --       "iconUrl": null,
    --       "id": null,
    --       "itemType": "Entity",
    --       "label": "Authorization Form",
    --       "objectApiName": "AuthorizationForm",
    --       "objectLabel": "Authorization Form",
    --       "objectLabelPlural": "Authorization Forms",
    --       "pageReference": {
    --         "attributes": {
    --           "objectApiName": "AuthorizationForm",
    --           "actionName": "home"
    --         },
    --         "state": {},
    --         "type": "standard__objectPage"
    --       },
    --       "standardType": null
    --     },
    --     {
    --       "availableInClassic": true,
    --       "availableInLightning": true,
    --       "color": null,
    --       "content": "https://pozil-dev-ed.my.salesforce.com/0cK/o",
    --       "custom": false,
    --       "developerName": "standard-AuthorizationFormConsent",
    --       "iconUrl": null,
    --       "id": null,
    --       "itemType": "Entity",
    --       "label": "Authorization Form Consent",
    --       "objectApiName": "AuthorizationFormConsent",
    --       "objectLabel": "Authorization Form Consent",
    --       "objectLabelPlural": "Authorization Form Consents",
    --       "pageReference": {
    --         "attributes": {
    --           "objectApiName": "AuthorizationFormConsent",
    --           "actionName": "home"
    --         },
    --         "state": {},
    --         "type": "standard__objectPage"
    --       },
    --       "standardType": null
    --     },
    --     {
    --       "availableInClassic": true,
    --       "availableInLightning": true,
    --       "color": null,
    --       "content": "https://pozil-dev-ed.my.salesforce.com/0cM/o",
    --       "custom": false,
    --       "developerName": "standard-AuthorizationFormDataUse",
    --       "iconUrl": null,
    --       "id": null,
    --       "itemType": "Entity",
    --       "label": "Authorization Form Data Use",
    --       "objectApiName": "AuthorizationFormDataUse",
    --       "objectLabel": "Authorization Form Data Use",
    --       "objectLabelPlural": "Authorization Form Data Uses",
    --       "pageReference": {
    --         "attributes": {
    --           "objectApiName": "AuthorizationFormDataUse",
    --           "actionName": "home"
    --         },
    --         "state": {},
    --         "type": "standard__objectPage"
    --       },
    --       "standardType": null
    --     }
    --   ],
    --   "nextPageUrl": "/services/data/v58.0/ui-api/nav-items?formFactor=Small&page=2&pageSize=5"
    -- }

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

    DECLARE @availableInClassic int

    DECLARE @availableInLightning int

    DECLARE @color nvarchar(4000)

    DECLARE @content nvarchar(4000)

    DECLARE @custom int

    DECLARE @developerName nvarchar(4000)

    DECLARE @iconUrl nvarchar(4000)

    DECLARE @id nvarchar(4000)

    DECLARE @itemType nvarchar(4000)

    DECLARE @label nvarchar(4000)

    DECLARE @objectApiName nvarchar(4000)

    DECLARE @objectLabel nvarchar(4000)

    DECLARE @objectLabelPlural nvarchar(4000)

    DECLARE @ObjectApiName nvarchar(4000)

    DECLARE @ActionName nvarchar(4000)

    DECLARE @v_Type nvarchar(4000)

    DECLARE @standardType nvarchar(4000)

    DECLARE @currentPageUrl nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @currentPageUrl OUT, 'currentPageUrl'
    DECLARE @eTag nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @eTag OUT, 'eTag'
    DECLARE @nextPageUrl nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @nextPageUrl OUT, 'nextPageUrl'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'navItems'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'BoolOf', @availableInClassic OUT, 'navItems[i].availableInClassic'
        EXEC sp_OAMethod @jResp, 'BoolOf', @availableInLightning OUT, 'navItems[i].availableInLightning'
        EXEC sp_OAMethod @jResp, 'StringOf', @color OUT, 'navItems[i].color'
        EXEC sp_OAMethod @jResp, 'StringOf', @content OUT, 'navItems[i].content'
        EXEC sp_OAMethod @jResp, 'BoolOf', @custom OUT, 'navItems[i].custom'
        EXEC sp_OAMethod @jResp, 'StringOf', @developerName OUT, 'navItems[i].developerName'
        EXEC sp_OAMethod @jResp, 'StringOf', @iconUrl OUT, 'navItems[i].iconUrl'
        EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'navItems[i].id'
        EXEC sp_OAMethod @jResp, 'StringOf', @itemType OUT, 'navItems[i].itemType'
        EXEC sp_OAMethod @jResp, 'StringOf', @label OUT, 'navItems[i].label'
        EXEC sp_OAMethod @jResp, 'StringOf', @objectApiName OUT, 'navItems[i].objectApiName'
        EXEC sp_OAMethod @jResp, 'StringOf', @objectLabel OUT, 'navItems[i].objectLabel'
        EXEC sp_OAMethod @jResp, 'StringOf', @objectLabelPlural OUT, 'navItems[i].objectLabelPlural'
        EXEC sp_OAMethod @jResp, 'StringOf', @ObjectApiName OUT, 'navItems[i].pageReference.attributes.objectApiName'
        EXEC sp_OAMethod @jResp, 'StringOf', @ActionName OUT, 'navItems[i].pageReference.attributes.actionName'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'navItems[i].pageReference.type'
        EXEC sp_OAMethod @jResp, 'StringOf', @standardType OUT, 'navItems[i].standardType'
        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}}/ui-api/nav-items

Postman Collection Item JSON

{
  "name": "Get All Navigation Items",
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/nav-items",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "ui-api",
        "nav-items"
      ],
      "query": [
        {
          "key": "formFactor",
          "value": "Small",
          "description": "The form factor for each app that the user has access to (`Large`, `Medium` or `Small`)",
          "disabled": true
        },
        {
          "key": "navItemNames",
          "value": "",
          "description": "A comma delimited list of TabDefinition name values to include in the response.",
          "disabled": true
        },
        {
          "key": "page",
          "value": "",
          "description": "The page offset form which to begin returning nav items. The default value is 0, which returns nav items from the first page. For example, for `page=2` and `pageSize=10`, the first nav item returned is the 21st nav item in the list.",
          "disabled": true
        },
        {
          "key": "pageSize",
          "value": "",
          "description": "The maximum number of nav items to return on a page. The default value is 25.",
          "disabled": true
        }
      ]
    },
    "description": "Gets all navigation items (tabs) that the user has access to."
  },
  "response": [
    {
      "name": "Get All Navigation Items",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/nav-items?formFactor=Small&page=1&pageSize=5",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "ui-api",
            "nav-items"
          ],
          "query": [
            {
              "key": "formFactor",
              "value": "Small",
              "description": "The form factor for each app that the user has access to (`Large`, `Medium` or `Small`)"
            },
            {
              "key": "navItemNames",
              "value": null,
              "description": "A comma delimited list of TabDefinition name values to include in the response.",
              "disabled": true
            },
            {
              "key": "page",
              "value": "1",
              "description": "The page offset form which to begin returning nav items. The default value is 0, which returns nav items from the first page. For example, for `page=2` and `pageSize=10`, the first nav item returned is the 21st nav item in the list."
            },
            {
              "key": "pageSize",
              "value": "5",
              "description": "The maximum number of nav items to return on a page. The default value is 25."
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Fri, 06 Oct 2023 09:45:07 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": "ETag",
          "value": "\"425dfe9232c5bd0e9c6e4b94771c91b8--gzip\""
        },
        {
          "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    \"currentPageUrl\": \"/services/data/v58.0/ui-api/nav-items?formFactor=Small&page=1&pageSize=5\",\n    \"eTag\": \"425dfe9232c5bd0e9c6e4b94771c91b8\",\n    \"navItems\": [\n        {\n            \"availableInClassic\": true,\n            \"availableInLightning\": true,\n            \"color\": null,\n            \"content\": \"https://pozil-dev-ed.my.salesforce.com/4nK/o\",\n            \"custom\": false,\n            \"developerName\": \"standard-AssetStatePeriod\",\n            \"iconUrl\": null,\n            \"id\": null,\n            \"itemType\": \"Entity\",\n            \"label\": \"Asset State Periods\",\n            \"objectApiName\": \"AssetStatePeriod\",\n            \"objectLabel\": \"Asset State Period\",\n            \"objectLabelPlural\": \"Asset State Periods\",\n            \"pageReference\": {\n                \"attributes\": {\n                    \"objectApiName\": \"AssetStatePeriod\",\n                    \"actionName\": \"home\"\n                },\n                \"state\": {},\n                \"type\": \"standard__objectPage\"\n            },\n            \"standardType\": null\n        },\n        {\n            \"availableInClassic\": true,\n            \"availableInLightning\": true,\n            \"color\": null,\n            \"content\": \"https://pozil-dev-ed.my.salesforce.com/02i/o\",\n            \"custom\": false,\n            \"developerName\": \"standard-Asset\",\n            \"iconUrl\": null,\n            \"id\": null,\n            \"itemType\": \"Entity\",\n            \"label\": \"Assets\",\n            \"objectApiName\": \"Asset\",\n            \"objectLabel\": \"Asset\",\n            \"objectLabelPlural\": \"Assets\",\n            \"pageReference\": {\n                \"attributes\": {\n                    \"objectApiName\": \"Asset\",\n                    \"actionName\": \"home\"\n                },\n                \"state\": {},\n                \"type\": \"standard__objectPage\"\n            },\n            \"standardType\": null\n        },\n        {\n            \"availableInClassic\": true,\n            \"availableInLightning\": true,\n            \"color\": null,\n            \"content\": \"https://pozil-dev-ed.my.salesforce.com/0cI/o\",\n            \"custom\": false,\n            \"developerName\": \"standard-AuthorizationForm\",\n            \"iconUrl\": null,\n            \"id\": null,\n            \"itemType\": \"Entity\",\n            \"label\": \"Authorization Form\",\n            \"objectApiName\": \"AuthorizationForm\",\n            \"objectLabel\": \"Authorization Form\",\n            \"objectLabelPlural\": \"Authorization Forms\",\n            \"pageReference\": {\n                \"attributes\": {\n                    \"objectApiName\": \"AuthorizationForm\",\n                    \"actionName\": \"home\"\n                },\n                \"state\": {},\n                \"type\": \"standard__objectPage\"\n            },\n            \"standardType\": null\n        },\n        {\n            \"availableInClassic\": true,\n            \"availableInLightning\": true,\n            \"color\": null,\n            \"content\": \"https://pozil-dev-ed.my.salesforce.com/0cK/o\",\n            \"custom\": false,\n            \"developerName\": \"standard-AuthorizationFormConsent\",\n            \"iconUrl\": null,\n            \"id\": null,\n            \"itemType\": \"Entity\",\n            \"label\": \"Authorization Form Consent\",\n            \"objectApiName\": \"AuthorizationFormConsent\",\n            \"objectLabel\": \"Authorization Form Consent\",\n            \"objectLabelPlural\": \"Authorization Form Consents\",\n            \"pageReference\": {\n                \"attributes\": {\n                    \"objectApiName\": \"AuthorizationFormConsent\",\n                    \"actionName\": \"home\"\n                },\n                \"state\": {},\n                \"type\": \"standard__objectPage\"\n            },\n            \"standardType\": null\n        },\n        {\n            \"availableInClassic\": true,\n            \"availableInLightning\": true,\n            \"color\": null,\n            \"content\": \"https://pozil-dev-ed.my.salesforce.com/0cM/o\",\n            \"custom\": false,\n            \"developerName\": \"standard-AuthorizationFormDataUse\",\n            \"iconUrl\": null,\n            \"id\": null,\n            \"itemType\": \"Entity\",\n            \"label\": \"Authorization Form Data Use\",\n            \"objectApiName\": \"AuthorizationFormDataUse\",\n            \"objectLabel\": \"Authorization Form Data Use\",\n            \"objectLabelPlural\": \"Authorization Form Data Uses\",\n            \"pageReference\": {\n                \"attributes\": {\n                    \"objectApiName\": \"AuthorizationFormDataUse\",\n                    \"actionName\": \"home\"\n                },\n                \"state\": {},\n                \"type\": \"standard__objectPage\"\n            },\n            \"standardType\": null\n        }\n    ],\n    \"nextPageUrl\": \"/services/data/v58.0/ui-api/nav-items?formFactor=Small&page=2&pageSize=5\"\n}"
    }
  ]
}