Chilkat Online Tools

PowerBuilder / Salesforce Platform APIs / Get List View for an Object

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_ApiName
string ls_Id
string ls_Label
string ls_ListUiUrl
integer li_Count
string ls_CurrentPageToken
string ls_CurrentPageUrl
string ls_ETag
string ls_NextPageToken
string ls_NextPageUrl
string ls_ObjectApiName
integer li_PageSize
string ls_PreviousPageToken
string ls_PreviousPageUrl
string ls_QueryString
integer li_RecentListsOnly
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://domain.com/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "count": 6,
//   "currentPageToken": "0",
//   "currentPageUrl": "/services/data/v58.0/ui-api/list-ui/Account?pageSize=20&pageToken=0",
//   "eTag": "7a9cf6dc597cbc985bab8a26df2f1752",
//   "lists": [
//     {
//       "apiName": "AllAccounts",
//       "id": "00B58000002ssinEAA",
//       "label": "All Accounts",
//       "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/AllAccounts"
//     },
//     {
//       "apiName": "MyAccounts",
//       "id": "00B58000002ssivEAA",
//       "label": "My Accounts",
//       "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/MyAccounts"
//     },
//     {
//       "apiName": "NewLastWeek",
//       "id": "00B58000002ssiHEAQ",
//       "label": "New Last Week",
//       "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/NewLastWeek"
//     },
//     {
//       "apiName": "NewThisWeek",
//       "id": "00B58000002ssi6EAA",
//       "label": "New This Week",
//       "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/NewThisWeek"
//     },
//     {
//       "apiName": "PlatinumandGoldSLACustomers",
//       "id": "00B58000002ssiXEAQ",
//       "label": "Platinum and Gold SLA Customers",
//       "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/PlatinumandGoldSLACustomers"
//     },
//     {
//       "apiName": "RecentlyViewedAccounts",
//       "id": "00B58000002ssimEAA",
//       "label": "Recently Viewed Accounts",
//       "listUiUrl": "/services/data/v58.0/ui-api/list-ui/Account/RecentlyViewedAccounts"
//     }
//   ],
//   "nextPageToken": null,
//   "nextPageUrl": null,
//   "objectApiName": "Account",
//   "pageSize": 20,
//   "previousPageToken": null,
//   "previousPageUrl": null,
//   "queryString": null,
//   "recentListsOnly": false
// }

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

li_Count = loo_JResp.IntOf("count")
ls_CurrentPageToken = loo_JResp.StringOf("currentPageToken")
ls_CurrentPageUrl = loo_JResp.StringOf("currentPageUrl")
ls_ETag = loo_JResp.StringOf("eTag")
ls_NextPageToken = loo_JResp.StringOf("nextPageToken")
ls_NextPageUrl = loo_JResp.StringOf("nextPageUrl")
ls_ObjectApiName = loo_JResp.StringOf("objectApiName")
li_PageSize = loo_JResp.IntOf("pageSize")
ls_PreviousPageToken = loo_JResp.StringOf("previousPageToken")
ls_PreviousPageUrl = loo_JResp.StringOf("previousPageUrl")
ls_QueryString = loo_JResp.StringOf("queryString")
li_RecentListsOnly = loo_JResp.BoolOf("recentListsOnly")
i = 0
li_Count_i = loo_JResp.SizeOfArray("lists")
do while i < li_Count_i
    loo_JResp.I = i
    ls_ApiName = loo_JResp.StringOf("lists[i].apiName")
    ls_Id = loo_JResp.StringOf("lists[i].id")
    ls_Label = loo_JResp.StringOf("lists[i].label")
    ls_ListUiUrl = loo_JResp.StringOf("lists[i].listUiUrl")
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME

Postman Collection Item JSON

{
  "name": "Get List View for an Object",
  "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/list-ui/:SOBJECT_API_NAME",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "ui-api",
        "list-ui",
        ":SOBJECT_API_NAME"
      ],
      "query": [
        {
          "key": "pageSize",
          "value": "",
          "description": "The number of list records viewed at one time. The default value is 20. Value can be 1–2000.",
          "disabled": true
        },
        {
          "key": "pageToken",
          "value": "",
          "description": "A token that represents the page offset. To indicate where the page starts, use this value with the pageSize parameter. The maximum offset is 2000 and the default is 0.",
          "disabled": true
        },
        {
          "key": "q",
          "value": "",
          "description": "Query list views that contain certain key words.",
          "disabled": true
        },
        {
          "key": "recentListsOnly",
          "value": "true",
          "description": "Show only recently viewed lists.",
          "disabled": true
        }
      ],
      "variable": [
        {
          "key": "SOBJECT_API_NAME",
          "value": "Account",
          "description": "Object API name"
        }
      ]
    },
    "description": "Returns a collection of list views associated with an object."
  },
  "response": [
    {
      "name": "Get List View for an Object",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/list-ui/:SOBJECT_API_NAME",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "ui-api",
            "list-ui",
            ":SOBJECT_API_NAME"
          ],
          "query": [
            {
              "key": "pageSize",
              "value": null,
              "description": "The number of list records viewed at one time. The default value is 20. Value can be 1–2000.",
              "disabled": true
            },
            {
              "key": "pageToken",
              "value": null,
              "description": "A token that represents the page offset. To indicate where the page starts, use this value with the pageSize parameter. The maximum offset is 2000 and the default is 0.",
              "disabled": true
            },
            {
              "key": "q",
              "value": null,
              "description": "Query list views that contain certain key words.",
              "disabled": true
            },
            {
              "key": "recentListsOnly",
              "value": "true",
              "description": "Show only recently viewed lists.",
              "disabled": true
            }
          ],
          "variable": [
            {
              "key": "SOBJECT_API_NAME",
              "value": "Account",
              "description": "Object API name"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Fri, 06 Oct 2023 09:49:33 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": "\"7a9cf6dc597cbc985bab8a26df2f1752--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    \"count\": 6,\n    \"currentPageToken\": \"0\",\n    \"currentPageUrl\": \"/services/data/v58.0/ui-api/list-ui/Account?pageSize=20&pageToken=0\",\n    \"eTag\": \"7a9cf6dc597cbc985bab8a26df2f1752\",\n    \"lists\": [\n        {\n            \"apiName\": \"AllAccounts\",\n            \"id\": \"00B58000002ssinEAA\",\n            \"label\": \"All Accounts\",\n            \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/AllAccounts\"\n        },\n        {\n            \"apiName\": \"MyAccounts\",\n            \"id\": \"00B58000002ssivEAA\",\n            \"label\": \"My Accounts\",\n            \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/MyAccounts\"\n        },\n        {\n            \"apiName\": \"NewLastWeek\",\n            \"id\": \"00B58000002ssiHEAQ\",\n            \"label\": \"New Last Week\",\n            \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/NewLastWeek\"\n        },\n        {\n            \"apiName\": \"NewThisWeek\",\n            \"id\": \"00B58000002ssi6EAA\",\n            \"label\": \"New This Week\",\n            \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/NewThisWeek\"\n        },\n        {\n            \"apiName\": \"PlatinumandGoldSLACustomers\",\n            \"id\": \"00B58000002ssiXEAQ\",\n            \"label\": \"Platinum and Gold SLA Customers\",\n            \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/PlatinumandGoldSLACustomers\"\n        },\n        {\n            \"apiName\": \"RecentlyViewedAccounts\",\n            \"id\": \"00B58000002ssimEAA\",\n            \"label\": \"Recently Viewed Accounts\",\n            \"listUiUrl\": \"/services/data/v58.0/ui-api/list-ui/Account/RecentlyViewedAccounts\"\n        }\n    ],\n    \"nextPageToken\": null,\n    \"nextPageUrl\": null,\n    \"objectApiName\": \"Account\",\n    \"pageSize\": 20,\n    \"previousPageToken\": null,\n    \"previousPageUrl\": null,\n    \"queryString\": null,\n    \"recentListsOnly\": false\n}"
    }
  ]
}