REST QueryMore call returns only one record at a time
Last updated 2022-02-15 ·Reference W-1939405 ·Reported By 7 users
In Review
Summary
REST QueryMore returns only one record at a time, for requests retrieving additional query results if the query has a blob field in its select list.
When trying to query on objects with Blob fields like Body in Attachment, the first 2000 records are retrieved but the nextRecordsUrl only returns one record at a time. The nextRecordsUrl in result returns the next record and so forth.
This is because of the Query includes a blob field. This is also seen with Feed sObjects like AccountFeed (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_customobject__feed.htm) or even Knowledge articles that have attachments.
Repro
1. Prepare a large number of records (2000+) so that REST QueryMore requests can be called.
2. Open up workbench and go to REST explorer
3. Enter the query which contains a blob field and execute it.
/services/data/v45.0/query?q=SELECT%20Id%2CIsDeleted%2CName%2CContentType%2CBody%2CCreatedDate%20FROM%20Attachment
4. Click the link next to "nextRecordsUrl:"
Actual Result :
If the query results are too large, the link to retrieve additional results appears.
You will see only one record is retrieved.
/services/data/v45.0/query/01g1Y00008zOiDxQAK-2001
nextRecordsUrl in seen as increment by one.
/services/data/v45.0/query/01g1Y00008zOiDxQAK-2002
/services/data/v45.0/query/01g1Y00008zOiDxQAK-2003
/services/data/v45.0/query/01g1Y00008zOiDxQAK-2004
The Body info seen in the response is of the format:
"Body" : {
"asByteArray" : "dGVzdGluZw==",
"inputStream" : { },
"length" : 7,
"maxToKeep" : 524288
}
Expected Result
Next batch of 2000 results should be available in nextRecordsUrl consistently
Body info should be of the format :
Body: /services/data/v45.0/sobjects/Attachment/00P6F00002iuuB7UAI/Body
Workaround
Remove the Blob field from the query.
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.