To ensure consistent and atomic processing in OData batch requests:
✅ Use header Isolation: snapshot in your $batch request.🔄 Ensures the entire batch runs in one session.🔒 If no COMMIT is used in AL code → the whole batch runs as one transaction.🔁 If COMMIT is called → it ends the current transaction and starts a new one.📦 Ideal for grouped operations that must succeed or fail together.🛡 Helps maintain data integrity across multiple API operations.
{ "requests": [ { "method": "PATCH", "url": "items(xxxxxxx-0963-460f-9b1f-0014aea3e117)", "headers": { "Company": "CRONUS International Ltd.", "Content-Type": "application/json", "If-Match": "*" }, "body": { "displayName": "Touring Bicycle v2" } }, { "method": "PATCH", "url": "items(xxxxxxx-0963-460f-9b1f-0014aea3e117)/picture(xxxxxxx-0963-460f-9b1f-0014aea3e117)/contentValue", "headers": { "Company": "CRONUS International Ltd.", "Content-Type": "application/json", "If-Match": "*" }, "body": { "value": "Picture Blob" } }, { "method": "PATCH", "url": "items(xxxxxxx-0963-460f-9b1f-0014aea3e117)", "headers": { "Company": "CRONUS International Ltd.", "Content-Type": "application/json", "If-Match": "*" }, "body": { "type": "Invalid Type" } } ] } responses { "responses": [ { "id": null, "status": 200, "headers": { "content-type": "application/json; odata.metadata=minimal", "odata-version": "4.0" }, "body": { "displayName": "Touring Bicycle v2", // ... } }, { "id": null, "status": 204, "headers": {} }, { "id": null, "status": 400, "headers": { "content-type": "application/json; odata.metadata=minimal", "odata-version": "4.0" }, "body": { "error": { "code": "Unknown", "message": "'Invalid Type' is not an option. The existing options are: Inventory,Service,Non-Inventory CorrelationId: x." } } } ] }