BatchRequest Class

Builder for constructing and executing a Dataverse OData $batch request.

Obtain via new (client.batch.new()). Add operations through records, tables, query, and dataframe, optionally group writes into a changeset, then call execute.

Operations are executed sequentially in the order added. The resulting BatchResult contains one BatchItemResponse per HTTP request dispatched (some operations expand to multiple requests).

Note

Maximum 1000 HTTP operations per batch.

Example:


   batch = client.batch.new()
   batch.records.create("account", {"name": "Contoso"})
   batch.tables.get("account")
   with batch.changeset() as cs:
       ref = cs.records.create("contact", {"firstname": "Alice"})
       cs.records.update("account", account_id, {
           "primarycontactid@odata.bind": ref
       })
   result = batch.execute()

Constructor

BatchRequest(client: DataverseClient)

Parameters

Name Description
client
Required

Methods

changeset

Create a new ChangeSet attached to this batch.

The changeset is added to the batch immediately. Operations added to the returned ChangeSet via cs.records.* execute atomically.

Example:


   with batch.changeset() as cs:
       cs.records.create("account", {"name": "ACME"})
       cs.records.create("contact", {"firstname": "Bob"})
execute

Submit the batch to Dataverse and return all responses.

changeset

Create a new ChangeSet attached to this batch.

The changeset is added to the batch immediately. Operations added to the returned ChangeSet via cs.records.* execute atomically.

Example:


   with batch.changeset() as cs:
       cs.records.create("account", {"name": "ACME"})
       cs.records.create("contact", {"firstname": "Bob"})
changeset() -> ChangeSet

Returns

Type Description

A new ChangeSet ready to receive operations.

execute

Submit the batch to Dataverse and return all responses.

execute(*, continue_on_error: bool = False) -> BatchResult

Parameters

Name Description
continue_on_error
Required

When False (default), Dataverse stops at the first failure and returns that operation's error as a 4xx response. When True, Prefer: odata.continue-on-error is sent and all operations are attempted.

Keyword-Only Parameters

Name Description
continue_on_error
Default value: False

Returns

Type Description

BatchResult with one entry per HTTP operation in submission order.

Exceptions

Type Description

If the batch exceeds 1000 operations or an unsupported column type is specified.

If metadata pre-resolution fails (table or column not found) for tables.delete tables.add_columns tables.remove_columns

On HTTP-level failures (auth, server error, etc.) that prevent the batch from executing.