1

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?

2 Answers 2

1

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.

5
  • Ok, I guess would you know where in the Lightning Platform REST API, does it describe what this ID is and how is it generated?
    – Kris
    Apr 11, 2018 at 20:50
  • Kris, can you take a step back and edit your question to explain what exactly you are trying to do? Are you asking what a Salesforce record Id is?
    – David Reed
    Apr 11, 2018 at 20:52
  • Well, I'm at the step where I am updating the records, just as described here: developer.salesforce.com/docs/atlas.en-us.api_rest.meta/… However, I just took the 'record ID' from the recent to make it work and it works great. I update the record and I can see it has changed. I just don't understand where this 'record ID' comes from and how it fits into the 'big picture'.
    – Kris
    Apr 11, 2018 at 20:58
  • What is a Salesforce 'record id'? Where can I find out about this?
    – Kris
    Apr 11, 2018 at 21:00
  • It's... basically the global primary key of the database. Every record has an Id. This is one of the core elements of how Salesforce works.
    – David Reed
    Apr 11, 2018 at 21:30
1

As David explained, those are the recently viewed records. I'm not going to repeat everything he said so look at his answer.

As far as which url to use, the answer is most likely none.

The response contains a list of end points for performing various actions:

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

Most likely, you want to use one of these URLs.

As for which ID, your code should already have an object's ID or you should be obtaining that id using a different call (you can't rely on the recent items to contain the Id you're looking for). Then you simply append the ID to the endpoint for sobjects:

var endpoint = describeResponse.urls.sobject + '/' + record.Id;

that will get you the information for a specific record.

Documentation:

4
  • Yes, exactly how does one figure out where and how to get this ID? Where is the documentation for it?
    – Kris
    Apr 11, 2018 at 20:53
  • @Kris Updated my answer with a link to some documentation that could help you
    – gNerb
    Apr 11, 2018 at 20:54
  • @Kris All of the documentation you should need is in the left hand panel on that page you linked. That's where I found the two links I provided. You likely want to start with the "querying data" link as that will get you records that you want, then move to the "working with records" link.
    – gNerb
    Apr 11, 2018 at 21:03
  • Thank you, let me take a look at that link, it looks promising: developer.salesforce.com/docs/atlas.en-us.api_rest.meta/…
    – Kris
    Apr 11, 2018 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .