Salesforce - REST API
The following operations are supported:
-
getVersions - Gets supported Salesforce REST API versions.
-
getResources - Gets available Salesforce REST Resource endpoints.
-
limits - Lists information about limits in your org.
-
recent - Gets the most recently accessed items that were viewed or referenced by the current user.
-
getGlobalObjects - Gets metadata for all available SObject types.
-
getBasicInfo - Gets basic metadata for a specific SObject type.
-
getDescription - Gets comprehensive metadata for a specific SObject type.
-
getSObject - Gets an SObject.
-
getSObjectWithId - Gets an SObject using an External Id (user defined) field.
-
getBlobField - Retrieves the specified blob field from an individual record.
-
createSObject - Creates an SObject.
-
updateSObject - Updates an SObject.
-
deleteSObject - Deletes an SObject.
-
upsertSObject - Inserts or updates an SObject using an External Id.
-
deleteSObjectWithId - Deletes an SObject using an External Id.
-
query - Runs a Salesforce SOQL query.
-
queryMore - Retrieves more results (in case of a large number of results) using the result link returned from the 'query' API.
-
queryAll - Runs a SOQL query. Unlike the query operation, queryAll returns records that are deleted because of a merge or delete. queryAll also returns information about archived task and event records.
-
search - Runs a Salesforce SOSL query.
-
apexCall - Executes a user defined APEX REST API call.
-
approval - Submits a record or records (batch) for approval process.
-
approvals - Fetches a list of all approval processes.
-
composite - Executes up to 25 REST API requests in a single call. You can use the output of one request as the input to a subsequent request.
-
composite-tree - Creates up to 200 records with parent-child relationships (up to 5 levels) in one go.
-
composite-batch - Executes up to 25 sub-requests in a single request.
-
compositeRetrieveSObjectCollections - Retrieves one or more records of the same object type.
-
compositeCreateSObjectCollections - Creates up to 200 records.
-
compositeUpdateSObjectCollections - Update up to 200 records.
-
compositeUpsertSObjectCollections - Creates or updates up to 200 records based on an External Id field.
-
compositeDeleteSObjectCollections - Deletes up to 200 records.
-
getEventSchema - Gets the event schema for Platform Events, Change Data Capture events, etc.
Unless otherwise specified, DTO types for the following options are from org.apache.camel.component.salesforce.api.dto or one if its sub-packages.
Versions
getVersions
Lists summary information about each Salesforce version currently available, including the version, label, and a link to each version’s root.
Output
Type: List<Version>
Resources by Version
getResources
Lists available resources for the current API version, including resource name and URI.
Output
Type: Map<String, String>
Limits
limits
Lists information about limits in your org. For each limit, this resource returns the maximum allocation and the remaining allocation based on usage.
Output
Type: Limits
Additional Usage Information
With salesforce:limits operation you can fetch of API limits from Salesforce and then act upon that data received. The result of salesforce:limits operation is mapped to org.apache.camel.component.salesforce.api.dto.Limits class and can be used in a custom processors or expressions.
For instance, consider that you need to limit the API usage of Salesforce so that 10% of daily API requests is left for other routes. The body of output message contains an instance of org.apache.camel.component.salesforce.api.dto.Limits object that can be used in conjunction with Content Based Router and Content Based Router and Spring Expression Language (SpEL) to choose when to perform queries.
Notice how multiplying 1.0 with the integer value held in body.dailyApiRequests.remaining makes the expression evaluate as with floating point arithmetic, without it - it would end up making integral division which would result with either 0 (some API limits consumed) or 1 (no API limits consumed).
-
Java
-
XML
-
YAML
from("direct:querySalesforce")
.to("salesforce:limits")
.choice()
.when(spel("#{1.0 * body.dailyApiRequests.remaining / body.dailyApiRequests.max < 0.1}"))
.to("salesforce:query?...")
.otherwise()
.setBody(constant("Used up Salesforce API limits, leaving 10% for critical routes"))
.endChoice(); <route>
<from uri="direct:querySalesforce"/>
<to uri="salesforce:limits"/>
<choice>
<when>
<spel>#{1.0 * body.dailyApiRequests.remaining / body.dailyApiRequests.max < 0.1}</spel>
<to uri="salesforce:query?..."/>
</when>
<otherwise>
<setBody>
<constant>Used up Salesforce API limits, leaving 10% for critical routes</constant>
</setBody>
</otherwise>
</choice>
</route> - route:
from:
uri: direct:querySalesforce
steps:
- to:
uri: salesforce:limits
- choice:
when:
- spel: "#{1.0 * body.dailyApiRequests.remaining / body.dailyApiRequests.max < 0.1}"
steps:
- to:
uri: "salesforce:query?..."
otherwise:
steps:
- setBody:
constant: "Used up Salesforce API limits, leaving 10% for critical routes" Recently Viewed Items
recent
Gets the most recently accessed items that were viewed or referenced by the current user. Salesforce stores information about record views in the interface and uses it to generate a list of recently viewed and referenced records, such as in the sidebar and for the auto-complete options in search.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| An optional limit that specifies the maximum number of records to be returned. If this parameter is not specified, the default maximum number of records returned is the maximum number of entries in RecentlyViewed, which is 200 records per object. |
Output
Type: List<RecentItem>
Additional Usage Information
To fetch the recent items use salesforce:recent operation. This operation returns an java.util.List of org.apache.camel.component.salesforce.api.dto.RecentItem objects (List<RecentItem>) that in turn contain the Id, Name and Attributes (with type and url properties). You can limit the number of returned items by specifying limit parameter set to maximum number of records to return. For example:
-
Java
-
XML
-
YAML
from("direct:fetchRecentItems")
.to("salesforce:recent")
.split(body())
.log("${body.name} at ${body.attributes.url}"); <route>
<from uri="direct:fetchRecentItems"/>
<to uri="salesforce:recent"/>
<split>
<body/>
<log message="${body.name} at ${body.attributes.url}"/>
</split>
</route> - route:
from:
uri: direct:fetchRecentItems
steps:
- to:
uri: salesforce:recent
- split:
expression:
body: {}
steps:
- log: "${body.name} at ${body.attributes.url}" Describe Global
getGlobalObjects
Lists the available objects and their metadata for your organization’s data. In addition, it provides the organization encoding, as well as the maximum batch size permitted in queries.
Output
Type: GlobalObjects
sObject Basic Information
getBasicInfo
Describes the individual metadata for the specified object.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Name of SObject, e.g. | x |
Output
Type: SObjectBasicInfo
sObject Describe
getDescription
Completely describes the individual metadata at all levels for the specified object. For example, this can be used to retrieve the fields, URLs, and child relationships for the Account object.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Name of SObject, e.g. | x |
Output
Type: SObjectDescription
Retrieve SObject
getSObject
Accesses record based on the specified object ID. This operation requires the packages option to be set.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Name of SObject, e.g. | x | |
|
| Id of record to retrieve. | x | |
|
| Comma-separated list of fields to retrieve | ||
Body |
| Instance of SObject that is used to query salesforce. If supplied, overrides |
Output
Type: Subclass of AbstractSObjectBase
Retrieve SObject by External Id
getSObjectWithId
Accesses record based on an External ID value. This operation requires the packages option to be set.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| Name of External ID field | x | |
|
| External ID value | x | |
|
| Name of SObject, e.g. | x | |
Body |
| Instance of SObject that is used to query salesforce. If supplied, overrides |
Output
Type: Subclass of AbstractSObjectBase
sObject Blob Retrieve
getBlobField
Retrieves the specified blob field from an individual record.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
|
| SOSL query | x | |
|
| Name of SObject, e.g., Account | Required if SObject not supplied in body | |
|
| Id of SObject | Required if SObject not supplied in body | |
Body |
| SObject to determine type and Id from. If not supplied, | Required if |
Output
Type: InputStream
Create SObject
createSObject
Creates a record in salesforce.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Instance of SObject to create. | x | |
|
| Name of SObject, e.g. | If Body is a |
Output
Type: CreateSObjectResult
Multipart Support
When creating records with blob/binary fields, you can use the automatic multipart encoding feature by populating binary fields in your DTO. See Binary Fields and Multipart Requests for details.
Update SObject
updateSObject
Updates a record in salesforce.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Instance of SObject to update. | x | |
|
| Name of SObject, e.g. | If Body is a | |
|
| Id of record to update. Only used if Camel cannot determine from Body. | If Body is a |
Multipart Support
When updating records with blob/binary fields, you can use the automatic multipart encoding feature by populating binary fields in your DTO. See Binary Fields and Multipart Requests for details.
Upsert SObject
upsertSObject
Upserts a record by External ID.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| SObject to update. | x | |
|
| External ID field name. | x | |
|
| External ID value | If Body is a | |
|
| Name of SObject, e.g. | If Body is a |
Output
Type: UpsertSObjectResult
Delete SObject
deleteSObject
Deletes a record in salesforce.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Instance of SObject to delete. | ||
|
| Name of SObject, e.g. | If Body is not an | |
|
| Id of record to delete. | If Body is not an |
Delete SObject by External Id
deleteSObjectWithId
Deletes a record in salesforce by External ID.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Instance of SObject to delete. | ||
|
| Name of External ID field | If Body is not an | |
|
| External ID value | If Body is not an | |
|
| Name of SObject, e.g. | If Body is not an |
Query
query
Runs a Salesforce SOQL query. If neither sObjectClass nor sObjectName are set, Camel will attempt to determine the correct AbstractQueryRecordsBase sublcass based on the response.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body or |
| SOQL query | x | |
streamQueryResult |
| If true, returns a streaming | false | |
|
| Fully qualified name of class to deserialize response to. Usually a subclass of | ||
|
| Simple name of class to deserialize response to. Usually a subclass of |
Output
Type: Instance of class supplied in sObjectClass, or Iterator<SomeSObject> if streamQueryResult is true. If streamQueryResult is true, the header CamelSalesforceQueryResultTotalSize is set to the number of records that matched the query.
Query More
queryMore
Retrieves more results (in case of large number of results) using result link returned from the query and queryAll operations. If neither sObjectClass nor sObjectName are set, Camel will attempt to determine the correct AbstractQueryRecordsBase sublcass based on the response.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body or |
|
| X | |
|
| Fully qualified name of class to deserialize response to. Usually a subclass of | ||
|
| Simple name of class to deserialize response to. Usually a subclass of |
Output
Type: Instance of class supplied in sObjectClass
Query All
queryAll
Executes the specified SOQL query. Unlike the query operation , queryAll returns records that are deleted because of a merge or delete. It also returns information about archived task and event records. If neither sObjectClass nor sObjectName are set, Camel will attempt to determine the correct AbstractQueryRecordsBase sublcass based on the response.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body or |
| SOQL query | x | |
streamQueryResult |
| If true, returns a streaming | false | |
|
| Fully qualified name of class to deserialize response to. Usually a subclass of | ||
|
| Simple name of class to deserialize response to. Usually a subclass of |
Output
Type: Instance of class supplied in sObjectClass, or Iterator<SomeSObject> if streamQueryResult is true.
Search
search
Runs a Salesforce SOSL search
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body or |
| Name of field to retrieve | x |
Output
Type: SearchResult2
Submit Approval
approval
Submit a record or records (batch) for approval process.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
|
| ||
| Prefixed headers or endpoint options in lieu of passing an |
Output
Type: ApprovalResult
Additional usage information
All the properties are named exactly the same as in the Salesforce REST API prefixed with approval.. You can set approval properties by setting approval.PropertyName of the Endpoint these will be used as template — meaning that any property not present in either body or header will be taken from the Endpoint configuration. Or you can set the approval template on the Endpoint by assigning approval property to a reference onto a bean in the Registry.
You can also provide header values using the same approval.PropertyName in the incoming message headers.
And finally body can contain one AprovalRequest or an Iterable of ApprovalRequest objects to process as a batch.
The important thing to remember is the priority of the values specified in these three mechanisms:
-
value in body takes precedence before any other
-
value in message header takes precedence before template value
-
value in template is set if no other value in header or body was given
For example, to send one record for approval using values in headers use:
Given a route:
-
Java
-
XML
-
YAML
from("direct:example1")
.setHeader("approval.ContextId", simple("${body['contextId']}"))
.setHeader("approval.NextApproverIds", simple("${body['nextApproverIds']}"))
.to("salesforce:approval?approval.actionType=Submit&approval.comments=this is a test&approval.processDefinitionNameOrId=Test_Account_Process&approval.skipEntryCriteria=true"); <route>
<from uri="direct:example1"/>
<setHeader name="approval.ContextId">
<simple>${body['contextId']}</simple>
</setHeader>
<setHeader name="approval.NextApproverIds">
<simple>${body['nextApproverIds']}</simple>
</setHeader>
<to uri="salesforce:approval?approval.actionType=Submit&approval.comments=this is a test&approval.processDefinitionNameOrId=Test_Account_Process&approval.skipEntryCriteria=true"/>
</route> - route:
from:
uri: direct:example1
steps:
- setHeader:
name: approval.ContextId
simple: "${body['contextId']}"
- setHeader:
name: approval.NextApproverIds
simple: "${body['nextApproverIds']}"
- to:
uri: salesforce:approval
parameters:
approval.actionType: Submit
approval.comments: "this is a test"
approval.processDefinitionNameOrId: Test_Account_Process
approval.skipEntryCriteria: true You could send a record for approval using:
final Map<String, String> body = new HashMap<>();
body.put("contextId", accountIds.iterator().next());
body.put("nextApproverIds", userId);
final ApprovalResult result = template.requestBody("direct:example1", body, ApprovalResult.class); Composite
composite
Executes up to 25 REST API requests in a single call. You can use the output of one request as the input to a subsequent request. The response bodies and HTTP statuses of the requests are returned in a single response body. The entire series of requests counts as a single call toward your API limits. Use Salesforce Composite API to submit multiple chained requests. Individual requests and responses are linked with the provided reference.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Contains REST API sub-requests to be executed. | x | |
|
| Any (un)marshaling of requests and responses are assumed to be handled by the route | false | x |
|
| HTTP method to use for rawPayload requests. |
|
Output
Type: SObjectCompositeResponse
| Composite API supports only JSON payloads. |
| As with the batch API, the results can vary from API to API so the body of each |
Let’s look at an example:
SObjectComposite builders and ProducerTemplateSObjectComposite composite = new SObjectComposite("38.0", true);
// first insert operation via an external id
final Account updateAccount = new TestAccount();
updateAccount.setName("Salesforce");
updateAccount.setBillingStreet("Landmark @ 1 Market Street");
updateAccount.setBillingCity("San Francisco");
updateAccount.setBillingState("California");
updateAccount.setIndustry(Account_IndustryEnum.TECHNOLOGY);
composite.addUpdate("Account", "001xx000003DIpcAAG", updateAccount, "UpdatedAccount");
final Contact newContact = new TestContact();
newContact.setLastName("John Doe");
newContact.setPhone("1234567890");
composite.addCreate(newContact, "NewContact");
final AccountContactJunction__c junction = new AccountContactJunction__c();
junction.setAccount__c("001xx000003DIpcAAG");
junction.setContactId__c("@{NewContact.id}");
composite.addCreate(junction, "JunctionRecord");
final SObjectCompositeResponse response = template.requestBody("salesforce:composite", composite, SObjectCompositeResponse.class);
final List<SObjectCompositeResult> results = response.getCompositeResponse();
final SObjectCompositeResult accountUpdateResult = results.stream().filter(r -> "UpdatedAccount".equals(r.getReferenceId())).findFirst().get()
final int statusCode = accountUpdateResult.getHttpStatusCode(); // should be 200
final Map<String, ?> accountUpdateBody = accountUpdateResult.getBody();
final SObjectCompositeResult contactCreationResult = results.stream().filter(r -> "JunctionRecord".equals(r.getReferenceId())).findFirst().get() Using the rawPayload option
It’s possible to directly call Salesforce composite by preparing the Salesforce JSON request in the route thanks to the rawPayload option.
For instance, you can have the following route:
from("timer:fire?period=2000").setBody(constant("{\n" +
" \"allOrNone\" : true,\n" +
" \"records\" : [ { \n" +
" \"attributes\" : {\"type\" : \"FOO\"},\n" +
" \"Name\" : \"123456789\",\n" +
" \"FOO\" : \"XXXX\",\n" +
" \"ACCOUNT\" : 2100.0\n" +
" \"ExternalID\" : \"EXTERNAL\"\n"
" }]\n" +
"}")
.to("salesforce:composite?rawPayload=true")
.log("${body}"); The route directly creates the body as JSON and directly submit to salesforce endpoint using rawPayload=true option.
With this approach, you have complete control on the Salesforce request.
POST is the default HTTP method used to send raw Composite requests to salesforce. Use the compositeMethod option to override to the other supported value, GET, which returns a list of other available composite resources.
Composite Tree
composite-tree
Create up to 200 records with parent-child relationships (up to 5 levels) in one go.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Contains REST API sub-requests to be executed. | x |
Output
Type: SObjectTree
To create up to 200 records including parent-child relationships use salesforce:composite-tree operation. This requires an instance of org.apache.camel.component.salesforce.api.dto.composite.SObjectTree in the input message and returns the same tree of objects in the output message. The org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase instances within the tree get updated with the identifier values (Id property) or their corresponding org.apache.camel.component.salesforce.api.dto.composite.SObjectNode is populated with errors on failure.
Note that for some records operation can succeed and for some it can fail — so you need to manually check for errors.
The easiest way to use this functionality is to use the DTOs generated by the camel-salesforce-maven-plugin, but you also have the option of customizing the references that identify each object in the tree, for instance primary keys from your database.
Let’s look at an example:
SObjectTree builders and ProducerTemplateAccount account = ...
Contact president = ...
Contact marketing = ...
Account anotherAccount = ...
Contact sales = ...
Asset someAsset = ...
// build the tree
SObjectTree request = new SObjectTree();
request.addObject(account).addChildren(president, marketing);
request.addObject(anotherAccount).addChild(sales).addChild(someAsset);
final SObjectTree response = template.requestBody("salesforce:composite-tree", tree, SObjectTree.class);
final Map<Boolean, List<SObjectNode>> result = response.allNodes()
.collect(Collectors.groupingBy(SObjectNode::hasErrors));
final List<SObjectNode> withErrors = result.get(true);
final List<SObjectNode> succeeded = result.get(false);
final String firstId = succeeded.get(0).getId(); Composite Batch
composite-batch
Submit a composition of requests in batch. Executes up to 25 sub-requests in a single request.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body |
| Contains sub-requests to be executed. | x |
Output
Type: SObjectBatchResponse
The Composite API batch operation allows you to accumulate multiple requests in a batch and then submit them in one go, saving the round trip cost of multiple individual requests. Each response is then received in a list of responses with the order preserved, so that the n-th requests response is in the n-th place of the response.
| The results can vary from API to API so the result of each sub-request ( |
Let’s look at an example:
SObjectBatch builders and ProducerTemplatefinal String acountId = ...
final SObjectBatch batch = new SObjectBatch("53.0");
final Account updates = new Account();
updates.setName("NewName");
batch.addUpdate("Account", accountId, updates);
final Account newAccount = new Account();
newAccount.setName("Account created from Composite batch API");
batch.addCreate(newAccount);
batch.addGet("Account", accountId, "Name", "BillingPostalCode");
batch.addDelete("Account", accountId);
final SObjectBatchResponse response = template.requestBody("salesforce:composite-batch", batch, SObjectBatchResponse.class);
boolean hasErrors = response.hasErrors(); // if any of the requests has resulted in either 4xx or 5xx HTTP status
final List<SObjectBatchResult> results = response.getResults(); // results of three operations sent in batch
final SObjectBatchResult updateResult = results.get(0); // update result
final int updateStatus = updateResult.getStatusCode(); // probably 204
final Object updateResultData = updateResult.getResult(); // probably null
final SObjectBatchResult createResult = results.get(1); // create result
@SuppressWarnings("unchecked")
final Map<String, Object> createData = (Map<String, Object>) createResult.getResult();
final String newAccountId = createData.get("id"); // id of the new account, this is for JSON, for XML it would be createData.get("Result").get("id")
final SObjectBatchResult retrieveResult = results.get(2); // retrieve result
@SuppressWarnings("unchecked")
final Map<String, Object> retrieveData = (Map<String, Object>) retrieveResult.getResult();
final String accountName = retrieveData.get("Name"); // Name of the retrieved account, this is for JSON, for XML it would be createData.get("Account").get("Name")
final String accountBillingPostalCode = retrieveData.get("BillingPostalCode"); // Name of the retrieved account, this is for JSON, for XML it would be createData.get("Account").get("BillingPostalCode")
final SObjectBatchResult deleteResult = results.get(3); // delete result
final int updateStatus = deleteResult.getStatusCode(); // probably 204
final Object updateResultData = deleteResult.getResult(); // probably null Retrieve Multiple Records with Fewer Round-Trips
compositeRetrieveSObjectCollections
Retrieve one or more records of the same object type.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
sObjectIds | List of String or comma-separated string | A list of one or more IDs of the objects to return. All IDs must belong to the same object type. | x | |
sObjectFields | List of String or comma-separated string | A list of fields to include in the response. The field names you specify must be valid, and you must have read-level permissions to each field. | x | |
sObjectName | String | Type of SObject, e.g. | x | |
sObjectClass | String | Fully qualified class name of DTO class to use for deserializing the response. | Required if |
Output
Type: List of class determined by sObjectName or sObjectClass header
Create SObject Collections
compositeCreateSObjectCollections
Add up to 200 records. Mixed SObject types is supported.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body | List of | A list of SObjects to create | x | |
| boolean | Indicates whether to roll back the entire request when the creation of any object fails (true) or to continue with the independent creation of other objects in the request. | false |
Output
Type: List<SaveSObjectResult>
Update SObject Collections
compositeUpdateSObjectCollections
Update up to 200 records. Mixed SObject types is supported.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body | List of | A list of SObjects to update | x | |
|
| Indicates whether to roll back the entire request when the update of any object fails (true) or to continue with the independent update of other objects in the request. | false |
Output
Type: List<SaveSObjectResult>
Upsert SObject Collections
compositeUpsertSObjectCollections
Create or update (upsert) up to 200 records based on an external ID field. Mixed SObject types is not supported.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
Body | List of | A list of SObjects to upsert | x | |
|
| Indicates whether to roll back the entire request when the upsert of any object fails (true) or to continue with the independent upsert of other objects in the request. | false | |
|
| Type of SObject, e.g. | x | |
|
| Name of External ID field | x |
Output
Type: List<UpsertSObjectResult>
Delete SObject Collections
compositeDeleteSObjectCollections
Delete up to 200 records. Mixed SObject types is supported.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
| List of String or comma-separated string | A list of up to 200 IDs of objects to be deleted. | x | |
| boolean | Indicates whether to roll back the entire request when the deletion of any object fails (true) or to continue with the independent deletion of other objects in the request. | false |
Output
Type: List<DeleteSObjectResult>
Get Event Schema
getEventSchema
Gets the definition of a Platform Event in JSON format. Other types of events such as Change Data Capture events or custom events are also supported. This operation is available in REST API version 40.0 and later.
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
| String | Name of event |
| |
| String | ID of a schema |
| |
| EventSchemaFormatEnum |
|
|
Output
Type: InputStream
Binary Fields and Multipart Requests
The Salesforce component provides automatic support for handling binary fields (blob fields) in SObjects without requiring manual base64 encoding. This feature works with both createSObject and updateSObject operations.
Binary Field Pattern
For any SObject with blob fields, you can use binary fields that follow the naming pattern ***Binary, where *** is the original field name. For example:
-
VersionDatafield →VersionDataBinaryfield -
Bodyfield →BodyBinaryfield -
ContentDatafield →ContentDataBinaryfield
Automatic Multipart Detection
When you populate a ***Binary field with an InputStream, the component automatically detects this and switches to multipart encoding for the request. This means that the binary data is sent directly as a stream, avoiding the overhead of base64 encoding.:
Usage Examples
Creating a ContentVersion with binary data:
// Create ContentVersion with binary field
ContentVersion cv = new ContentVersion();
cv.setTitle("My Document");
cv.setPathOnClient("document.pdf");
// Use binary field instead of base64 encoded string
InputStream fileData = new FileInputStream("document.pdf");
cv.setVersionDataBinary(fileData); // Automatically triggers multipart request
// Send to Salesforce
template.requestBody("salesforce:createSObject", cv); Updating a Document with binary content:
// Update Document with binary field
Document doc = new Document();
doc.setId("01234567890123456");
doc.setName("Updated Document");
// Use binary field for efficient upload
InputStream content = getClass().getResourceAsStream("/updated-content.pdf");
doc.setBodyBinary(content); // Automatically triggers multipart request
// Send to Salesforce
template.requestBody("salesforce:updateSObject", doc); DTO Generation
When using the Camel Salesforce Maven Plugin, binary fields are automatically generated for blob fields:
public class ContentVersion extends AbstractSObjectBase {
// Standard base64 field (for backward compatibility)
private String VersionData;
// Generated binary field (new efficient approach)
@JsonIgnore
private InputStream VersionDataBinary;
// Getters and setters for both fields...
} Field Priority
When both the standard field and binary field are populated:
-
Binary field takes precedence - The
***Binaryfield is used and a multipart request is made -
Standard field is ignored - The base64 string field is not sent in the multipart request
-
Automatic cleanup - Binary field names are automatically removed from the JSON payload
Performance Benefits
Using binary fields provides significant performance improvements:
-
No base64 encoding required on the client side
-
Direct streaming of binary data to Salesforce
-
Reduced memory usage for large files
-
Faster upload times especially for large documents
-
Higher salesforce limits for multipart requests compared to base64 strings. Salesforce limits base64 strings to 50 MB of text data or 37.5 MB of base64-encoded data. Multipart uploads can handle 2 GB for ContentVersion records, and 500 MB for all other objects.
Backward Compatibility
The existing base64 string approach continues to work:
// Still supported - base64 approach
ContentVersion cv = new ContentVersion();
cv.setVersionData(base64EncodedString); // Uses standard JSON request However, using binary fields is recommended for better performance when working with binary data.