Batch
Batch command requests can take multiple state commands and batch them together into a single transaction. This is useful for grouping cohesive operations together resulting in an "all or nothing" approach to the execution. If one of the commands fail, the whole batch is rolled back.
Request
POST /{languageCode}/{companyNumber}/api/v1/Batch HTTP/1.1
Host: {host}:8001
Content-Type: application/json
Cache-Control: no-cache
Accept: application/json
X-Monitor-SessionId: {sessionId}
{body}
See Request for more information about requests.
Request body
The body of the request must be a JSON-encoded array of BatchCommandEntity objects.
A BatchCommandEntity contains the path to the command that you want to execute (excluding the API base URL) as well as the command itself encoded as JSON.
Simulate/Validate
Batch command requests also support simulation and validation much like ordinary
command requests. Simply suffix the request URL with /Validate
or /Simulate
.
See Simulate/Validate for more information.
Result forwarding
To provide cohesion between commands in a batch, the result of a command can be forwarded and received by the next command in the batch.
ForwardPropertyName
By setting the BatchCommandEntity.ForwardPropertyName
, you specify which
property from the result that you want to forward to the next command in
the batch. The properties to choose from here are limited to the properties
available on EntityCommandResponse.
ReceivingPropertyName
By setting the BatchCommandEntity.ReceivingPropertyName
, you specify which
property should receive the value forwarded from the previous command in
the batch.