How does Batch Apply Actions Evaluate if one of the actions errors out?

I’m interested in using batch apply actions through OSDK to create objects:

  • We have some business logic that will throw a UserFacingError if one of the parameters is incorrect, and not create the object:

  • If 1 of the 20 objects creations throws an error, will all 20 fail?

  • Will the error response be returned as an array of responses? The docs just give {} as a sample response

I was curious about this too, so I tested it out. Short answer: if any of the actions don’t pass validation, the entire request fails with a Default: Internal error name. The valid actions in the request were also aborted.

To test, I set a validation rule that will reject the action if property_a is set equal to “bad”

Test1:

Request

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer $TOKEN" \
	"https://{STACK}/api/v1/ontologies/{ontology-id}/actions/{action-id}/applyBatch" \
	-d '{"requests":[{"parameters":{"id": "1","property_a":"test"}},{"parameters":{"id": "2","property_a":"bad"}}]}'

Response

{"errorCode":"INTERNAL","errorName":"Default:Internal","errorInstanceId":"8c37a7c9-3cdb-4735-8f80-a5a219ce5b63","parameters":{}}

Test2:

Request

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer $TOKEN" \
	"https://{STACK}/api/v1/ontologies/{ontology-id}/actions/{action-id}/applyBatch" \
	-d '{"requests":[{"parameters":{"id": "1","property_a":"test"}},{"parameters":{"id": "2","property_a":"test"}}]}'

Response

{}

I see, thanks for testing that! Is there an alternative solution then, other than completing separate API calls for each object?