Predict and diagnose API failures
These two short activities check your model of the failure patterns in this module before the knowledge check. Decide each answer before you read it.
Predict the outcome of a concurrency conflict
Two fulfillment coordinators open the same equipment request at the same moment. Both clients retrieve the record with the ETag W/"12345". Coordinator A saves first, sending a PATCH with If-Match: W/"12345", and the update succeeds.
- Coordinator B then saves, sending a
PATCHwith the sameIf-Match: W/"12345"header. What does the Web API return? - Coordinator B's app uses the SDK for .NET instead, with
ConcurrencyBehavior.IfRowVersionMatcheson theUpdateRequest. What happens? - What should Coordinator B's code do next?
- Coordinator B's app sends its
PATCHwith noIf-Matchheader at all. What happens to Coordinator A's change?
Check your predictions:
412 Precondition Failed. The record changed after B retrieved it, so the ETag no longer matches.- The SDK throws a fault with the code
ConcurrencyVersionMismatch. - Re-retrieve the current record and decide how to reconcile the two changes. Retrying the same write fails the same way.
- B's update succeeds and silently overwrites A's change, because nothing told Dataverse to check the version.
Diagnose an authentication failure
The external inventory service authenticates as a confidential client. For each symptom, decide which layer is rejecting the call, Microsoft Entra ID or Dataverse, and what you check first.
- Token acquisition fails because the service requests a
user_impersonationscope. - The service gets a token, but every call to Dataverse fails as if it has no access to any data.
- The service can read
devicerecords, but every write todevicefails. - Calls work for an hour, then fail every time the service resends the token it already has.
Check your diagnoses:
- Entra ID. A service with no signed-in user requests the
<environment-url>/.defaultscope, not the delegateduser_impersonationscope. - Dataverse. Check that an application user exists for the app registration and has a security role assigned.
- Dataverse. The application user's security role doesn't grant write access to
device. - Token lifetime. The token expired. Re-acquire a fresh token before expiry instead of resending the stale one.
If any answer surprised you, reread the section it comes from before the knowledge check.