[SalesForce] With Salesforce REST API sobjects how does one decide which ID is used

There is documentation on Salesforce website named "Introducing Lightning Platform REST API" and the link is the following:

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_describeGlobal.htm

When I run a query similar in the example, but on "System__c" object like the following:

curl https://instance.salesforce.com/services/data/v42.0/sobjects/System__c -H "Authorization: Bearer ACTUAL_TOKEN" -H "X-PrettyPrint:1"

The output is the following:

    {
      "objectDescribe" : {
        "activateable" : false,
        "createable" : true,
        "custom" : true,
        "customSetting" : false,
        "deletable" : true,
        "deprecatedAndHidden" : false,
        "feedEnabled" : true,
        "hasSubtypes" : false,
        "isSubtype" : false,
        "keyPrefix" : "a01",
        "label" : "System",
        "labelPlural" : "Systems",
        "layoutable" : true,
        "mergeable" : false,
        "mruEnabled" : true,
        "name" : "System__c",
        "queryable" : true,
        "replicateable" : true,
        "retrieveable" : true,
        "searchable" : true,
        "triggerable" : true,
        "undeletable" : true,
        "updateable" : true,
        "urls" : {
          "compactLayouts" : "/services/data/v42.0/sobjects/System__c/describe/compactLayouts",
          "rowTemplate" : "/services/data/v42.0/sobjects/System__c/{ID}",
          "approvalLayouts" : "/services/data/v42.0/sobjects/System__c/describe/approvalLayouts",
          "defaultValues" : "/services/data/v42.0/sobjects/System__c/defaultValues?recordTypeId&fields",
          "describe" : "/services/data/v42.0/sobjects/System__c/describe",
          "quickActions" : "/services/data/v42.0/sobjects/System__c/quickActions",
          "layouts" : "/services/data/v42.0/sobjects/System__c/describe/layouts",
          "sobject" : "/services/data/v42.0/sobjects/System__c"
        }
      },
      "recentItems" : [ {
        "attributes" : {
          "type" : "System__c",
          "url" : "/services/data/v42.0/sobjects/System__c/b02f000000MCbLwAAL"
        },
        "Id" : "b02f000000MCbLwAAL",
        "Name" : "S000040"
      }, {
        "attributes" : {
          "type" : "System__c",
          "url" : "/services/data/v42.0/sobjects/System__c/b02f000000M3qsPAAR"
        },
        "Id" : "b02f000000M3qsPAAR",
        "Name" : "S000046"
      }, {
        "attributes" : {
          "type" : "System__c",
          "url" : "/services/data/v42.0/sobjects/System__c/b02f000000M3AQcAAN"
        },
        "Id" : "b02f000000M3AQcAAN",
        "Name" : "S000045"
      } ]
    }

Notice that the bottom of the JSON response has three URL's with different IDs:

    "Id" : "b02f000000MCbLwAAL",
    "Id" : "b02f000000M3qsPAAR",
    "Id" : "b02f000000M3AQcAAN",

To create a URL to access the data, it would have to look like:
https://instance.salesforce.com/services/data/v42.0/sobjects/system__c/b02f000000MCbLwAAL

How do I determine which ID I need to use for the URL?

Best Answer

The endpoint you are hitting is performing a Describe call, which returns details about the object's definition, not its records. The response includes the Ids of a certain number of recently viewed records of this type. Notice that the enclosing key is 'recentItems'.

You can, if you wish, perform a query to obtain the data for any or all of these objects, but the endpoint that you are hitting is not performing a query against this object.

Related Topic