Salesforce - REST API

The following operations are supported:

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 &lt; 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

limit

int

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

sObjectName

String

Name of SObject, e.g. Account. Alternatively, can be supplied in Body.

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

sObjectName

String

Name of SObject, e.g. Account. Alternatively, can be supplied in Body.

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

sObjectName

String

Name of SObject, e.g. Account

x

sObjectId

String

Id of record to retrieve.

x

sObjectFields

String

Comma-separated list of fields to retrieve

Body

AbstractSObjectBase

Instance of SObject that is used to query salesforce. If supplied, overrides sObjectName and sObjectId parameters.

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

sObjectIdName

String

Name of External ID field

x

sObjectIdValue

String

External ID value

x

sObjectName

String

Name of SObject, e.g. Account

x

Body

AbstractSObjectBase

Instance of SObject that is used to query salesforce. If supplied, overrides sObjectName and sObjectIdValue parameters.

Output

Type: Subclass of AbstractSObjectBase

sObject Blob Retrieve

getBlobField

Retrieves the specified blob field from an individual record.

Parameter Type Description Default Required

sObjectBlobFieldName

String

SOSL query

x

sObjectName

String

Name of SObject, e.g., Account

Required if SObject not supplied in body

sObjectId

String

Id of SObject

Required if SObject not supplied in body

Body

AbstractSObjectBase

SObject to determine type and Id from. If not supplied, sObjectId and sObjectName parameters will be used.

Required if sObjectId and sObjectName are not supplied

Output

Type: InputStream

Create SObject

createSObject

Creates a record in salesforce.

Parameter Type Description Default Required

Body

AbstractSObjectBase or String

Instance of SObject to create.

x

sObjectName

String

Name of SObject, e.g. Account. Only used if Camel cannot determine from Body.

If Body is a String

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

AbstractSObjectBase or String

Instance of SObject to update.

x

sObjectName

String

Name of SObject, e.g. Account. Only used if Camel cannot determine from Body.

If Body is a String

sObjectId

String

Id of record to update. Only used if Camel cannot determine from Body.

If Body is a String

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

AbstractSObjectBase or String

SObject to update.

x

sObjectIdName

String

External ID field name.

x

sObjectIdValue

String

External ID value

If Body is a String

sObjectName

String

Name of SObject, e.g. Account. Only used if Camel cannot determine from Body.

If Body is a String

Output

Type: UpsertSObjectResult

Delete SObject

deleteSObject

Deletes a record in salesforce.

Parameter Type Description Default Required

Body

AbstractSObjectBase

Instance of SObject to delete.

sObjectName

String

Name of SObject, e.g. Account. Only used if Camel cannot determine from Body.

If Body is not an AbstractSObjectBase instance

sObjectId

String

Id of record to delete.

If Body is not an AbstractSObjectBase instance

Delete SObject by External Id

deleteSObjectWithId

Deletes a record in salesforce by External ID.

Parameter Type Description Default Required

Body

AbstractSObjectBase

Instance of SObject to delete.

sObjectIdName

String

Name of External ID field

If Body is not an AbstractSObjectBase instance

sObjectIdValue

String

External ID value

If Body is not an AbstractSObjectBase instance

sObjectName

String

Name of SObject, e.g. Account. Only used if Camel cannot determine from Body.

If Body is not an AbstractSObjectBase instance

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 sObjectQuery

String

SOQL query

x

streamQueryResult

Boolean

If true, returns a streaming Iterator and transparently retrieves all pages as needed. The sObjectClass option must reference an AbstractQueryRecordsBase subclass.

false

sObjectClass

String

Fully qualified name of class to deserialize response to. Usually a subclass of AbstractQueryRecordsBase, e.g. org.my.dto.QueryRecordsAccount

sObjectName

String

Simple name of class to deserialize response to. Usually a subclass of AbstractQueryRecordsBase, e.g. QueryRecordsAccount. Requires the package option be set.

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 sObjectQuery

String

nextRecords value. Can be found in a prior query result in the AbstractQueryRecordsBase.nextRecordsUrl property

X

sObjectClass

String

Fully qualified name of class to deserialize response to. Usually a subclass of AbstractQueryRecordsBase, e.g. org.my.dto.QueryRecordsAccount

sObjectName

String

Simple name of class to deserialize response to. Usually a subclass of AbstractQueryRecordsBase, e.g. QueryRecordsAccount. Requires the package option be set.

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 sObjectQuery

String

SOQL query

x

streamQueryResult

Boolean

If true, returns a streaming Iterable and transparently retrieves all pages as needed. The sObjectClass option must reference an AbstractQueryRecordsBase subclass.

false

sObjectClass

String

Fully qualified name of class to deserialize response to. Usually a subclass of AbstractQueryRecordsBase, e.g. org.my.dto.QueryRecordsAccount

sObjectName

String

Simple name of class to deserialize response to. Usually a subclass of AbstractQueryRecordsBase, e.g. QueryRecordsAccount. Requires the package option be set.

Output

Type: Instance of class supplied in sObjectClass, or Iterator<SomeSObject> if streamQueryResult is true.

search

Runs a Salesforce SOSL search

Parameter Type Description Default Required

Body or sObjectSearch

String

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

ApprovalRequest or List<ApprovalRequest>

ApprovalRequest(s) to process

Approval.

Prefixed headers or endpoint options in lieu of passing an ApprovalRequest in the body.

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:

  1. value in body takes precedence before any other

  2. value in message header takes precedence before template value

  3. 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&amp;approval.comments=this is a test&amp;approval.processDefinitionNameOrId=Test_Account_Process&amp;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:

Java-only: ProducerTemplate test API
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);

Get Approvals

approvals

Returns a list of all approval processes.

Output

Type: Approvals

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

SObjectComposite

Contains REST API sub-requests to be executed.

x

rawPayload

Boolean

Any (un)marshaling of requests and responses are assumed to be handled by the route

false

x

compositeMethod

String

HTTP method to use for rawPayload requests.

POST

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 SObjectCompositeResult instance is given as a java.lang.Object. In most cases the result will be a java.util.Map with string keys and values or other java.util.Map as value. Requests are made in JSON format hold some type information (i.e., it is known what values are strings and what values are numbers).

Let’s look at an example:

Java-only: uses SObjectComposite builders and ProducerTemplate
SObjectComposite 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

SObjectTree

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:

Java-only: uses SObjectTree builders and ProducerTemplate
Account 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

SObjectBatch

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 (SObjectBatchResult.result) is given as a java.lang.Object. In most cases the result will be a java.util.Map with string keys and values or other java.util.Map as value. Requests are made in JSON format and hold some type information (i.e., it is known what values are strings and what values are numbers).

Let’s look at an example:

Java-only: uses SObjectBatch builders and ProducerTemplate
final 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. Account

x

sObjectClass

String

Fully qualified class name of DTO class to use for deserializing the response.

Required if sObjectName parameter does not resolve to a class that exists in the package specified by the package option.

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 SObject

A list of SObjects to create

x

allOrNone

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 SObject

A list of SObjects to update

x

allOrNone

boolean

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 SObject

A list of SObjects to upsert

x

allOrNone

boolean

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

sObjectName

String

Type of SObject, e.g. Account

x

sObjectIdName

String

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

sObjectIds or request body

List of String or comma-separated string

A list of up to 200 IDs of objects to be deleted.

x

allOrNone

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

eventName

String

Name of event

eventName or eventSchemaId is required

eventSchemaId

String

ID of a schema

eventName or eventSchemaId is required

eventSchemaFormat

EventSchemaFormatEnum

EXPANDED: Apache Avro format but doesn’t strictly adhere to the record complex type. COMPACT: Apache Avro, adheres to the specification for the record complex type. This parameter is available in API version 43.0 and later.

EXPANDED

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:

  • VersionData field → VersionDataBinary field

  • Body field → BodyBinary field

  • ContentData field → ContentDataBinary field

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:

Java-only: uses generated DTO classes and ProducerTemplate
// 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:

Java-only: uses generated DTO classes and ProducerTemplate
// 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:

Java-only: generated DTO class
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 ***Binary field 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:

Java-only: Salesforce DTO API
// 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.