Retrieving Failed Objects from the ExecuteMultipleResponse Method
1 answer
Assuming you create yours ExecuteMultipleRequest
something like this:
var entityCollection; // your EntityCollection
var requests = new ExecuteMultipleRequest();
foreach (var entity in entityCollection.Entities) {
var upsertRequest = new UpsertRequest { Target = entity };
requests.Requests.Add(upsertRequest);
}
You should be able to execute the query, iterate through it, responses
and for each determine if an error occurred:
var responses = service.Execute(requests);
var errors = new List<Entity>();
foreach (var response in responses.Responses) {
if (response.Fault != null) {
var entity = entityCollection[response.RequestIndex];
errors.Add(entity);
}
}
response.RequestIndex
is used to access the corresponding response request by matching their indices.
responses.Responses
contains a set ExecuteMultipleResponseItem
. Documentation about their properties can be found here .
+3
source to share