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:
BatchRequestCompositeRequest
-
Builder:
BatchRequestBuilderCompositeRequestBuilder
-
Response:
BatchResponseCompositeRequestBuilder
These classes make it easy to create batch and composite requests. To use them:
-
Create a builder instance. For batch requests, you can optionally set
haltOnErrorproperty to true:- Kotlin
- Java
For composite requests, you can optionally set the
allOrNonerollback property to true.- Kotlin
- Java
-
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
RestRequestobject:- Kotlin
- Java
-
When you’re ready, call the builder object’s build method:
- Kotlin
- Java
Each build method returns a specialized
RestRequestobject (BatchRestRequestorCompositeRestRequestinstance) that you can send through the sharedRestClient.sendAsync()method.To use an older API version as the default argument, pass a literal string in the format “v42.0”.
-
Responses to batch and composite requests arrive as instances of the response class (
BatchResponseorCompositeResponse).