Based on your error description and screenshot, I assume that you're doing it through programetically ( Apex, Python, Java...) and there is no time delay between your first request(extraction of data, /Query?q=) , response and the second request (details of the record based on ID, /sobjects/ObjectPermissions/{id})
- The records with '000' can be idntified as EmptyKeys in Salesforce and generally refers to null relationship values.
Contact is the lookup field on Opportunity and below queries will return the same count.
SELECT count() FROM opportunity WHERE contactId = null
SELECT count() FROM Opportunity WHERE contactId = '000000000000000AAA'
- In reference to the records in Object permission (starting with '000'), is little different from Empty keys and breakdown of the ids can be found in the blog
Mystery Behind The Salesforce Key Prefix '000'
- In the above scenario, we can't filter out these objects in Metadata API query, however we can filter the records before sending out the second request in APEX code.
Set responseIds - Response record Ids returned from First Request and process the Ids to filter out '000' Ids for second request.
String prefix = Schema.SobjectType.ObjectPermissions.getKeyPrefix();
for(String str : responseIds){
if(!str.subString(0,3).contains(prefix)){
responseIds.remove(str);
}
}
- RecentlyViewed object is not to be used directly. The IDs in this object are not ID belonging to the recentlyViewed Object, instead they are actual record ID's.
So if you intend to access the records from this object, you need to fetch the Ids from recentlyviewed Object then decode the keyprefix to get the proper sObject Name then use it this manner /sobjects/{decodedSobjectName}/{ID}
Or alternatively you can use /services/data/v48.0/recent (refer Salesforce documentation for details)
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_recent_items.htm
Although we have separate object for each standard picklist, they all share same keyprefix/objectType. The following code will remove all the request which are directed towards picklist objects (Taskstatus, Casestatus, solution status...)
for(Id str : responseIds){
if(Id.getsobjecttype() == 'Picklistmaster'){
responseIds.remove(str);
}
}
As for Loginhistory, the records later than 6 months will be deleted internally by salesforce. So if you run the 2 request (Query request, later data request) and if this 2 request happens to lie between the Salesforce maintenance window, then during your second request the id referred is already deleted from the org, hence the error. And make sure you have Manage Users permissions.