Batch and Composite Requests

Batch and composite APIs pose special challenges, because they handle multiple requests in a single call. Mobile SDK classes take the pain out of building and configuring these complex requests.

  • Request:

    • BatchRequest
    • CompositeRequest
  • Builder:

    • BatchRequestBuilder
    • CompositeRequestBuilder
  • Response:

    • BatchResponse
    • CompositeRequestBuilder

These classes make it easy to create batch and composite requests. To use them:

  1. Create a builder instance. For batch requests, you can optionally set haltOnError property to true:

    Kotlin

    Java

    For composite requests, you can optionally set the allOrNone rollback property to true.

    Kotlin

    Java

  2. As you create REST requests, add them to the builder object. For batch requests:

    Kotlin

    Java

    With composite requests, you also provide a reference ID as described in the REST API Developer Guide. You specify this ID when you add the RestRequest object:

    Kotlin

    Java

  3. When you’re ready, call the builder object’s build method:

    Kotlin

    Java

    Each build method returns a specialized RestRequest object (BatchRestRequest or CompositeRestRequest instance) that you can send through the shared RestClient.sendAsync() method.

    To use an older API version as the default argument, pass a literal string in the format “v42.0”.

  4. Responses to batch and composite requests arrive as instances of the response class (BatchResponse or CompositeResponse).