0

Bulk API 2.0 which is the most efficient way to fetch data in range between 2000 and 15000000, doesn't support binary (blob) data in ContentVersion VersionData and it also doesn't support Attachment object at all.

When we try to make a POST callout /services/data/v59.0/jobs/query with the body of

{
  "operation": "query",
  "query": "SELECT Id, ContentDocument.LatestPublishedVersionId, ContentDocument.LatestPublishedVersion.Title, ContentDocument.LatestPublishedVersion.FileExtension, ContentDocument.LatestPublishedVersion.FileType, ContentDocument.LatestPublishedVersion.TagCsv, ContentDocument.LatestPublishedVersion.ContentSize, ContentDocument.LatestPublishedVersion.VersionData FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Id FROM Opportunity)"
  }

an error is returned

enter image description here enter image description here

also if we try to execute POST callout /services/data/v59.0/jobs/query with the body of

{
  "operation": "query",
  "query": "SELECT Id, Body, ParentId  FROM Attachment WHERE ParentId IN (SELECT Id FROM Opportunity)"
  }

this also returns

400 Bad Request

[
    {
        "errorCode": "INVALIDJOB",
        "message": "Attachment is not a supported object"
    }
]

Data Export feature is not an option since it cannot be automated.

Should we try to use Bulk API 1.0 or REST API composite request?

Update: actually we can't even use Bulk API 1.0, it fails with an error

FeatureNotEnabled : Binary field not supported

This document mentions that

The sObject Blob Get resource isn’t compatible with Composite API requests, because it returns binary data instead of data in JSON or XML formats. Instead, make individual sObject Blob Get requests to retrieve blob data.

5
  • Use the REST API. The REST API allows for handling of binary data and can be used for complex queries, though it might not be as efficient for very large datasets compared to the Bulk API. Commented Dec 6, 2023 at 12:52
  • well, looks like REST API doesn't support Composite URL
    – Patlatus
    Commented Dec 6, 2023 at 12:53
  • You are correct, use Composite API that allows you to perform multiple operations in a single call. This can be used to efficiently handle multiple requests, including those involving complex objects or large sets of data. Commented Dec 6, 2023 at 12:57
  • if using a 3rd party backup system (e.g. OwnBackup), perhaps you can query their API to get blobs in bulk? (I have not tried this)
    – cropredy
    Commented Dec 6, 2023 at 21:35
  • well, I am not sure how particular 3rd party backup system works, however, in general it is also limited in the same API tools that are available. So they are either doing single calls for content bodies or screenscraping weekly export service ui
    – Patlatus
    Commented Dec 7, 2023 at 12:34

1 Answer 1

0

Looks like there is no way to retrieve Blob binary data in bulk. Neither through SOAP API nor through REST API or Bulk API.

The sObject Blob Get resource isn’t compatible with Composite API requests, because it returns binary data instead of data in JSON or XML formats. Instead, make individual sObject Blob Get requests to retrieve blob data.

The only option is to perform one call at a time like

GET /services/data/v59.0/sobjects/ContentVersion/0680600000XHj0dAAD/VersionData

One plausible option might be to configure weekly exports for Attachments and Files and screenscrape to extract those files, but screenscraping option is usually discouraged because of its instability

You must log in to answer this question.

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