Error 0x80040237: Duplicate Records and Missing References

What this error means: Error code 0x80040237 is used by Dynamics 365 for multiple different scenarios. This error code is not officially documented by Microsoft, making it particularly challenging to troubleshoot. Use the HTTP status code and error message to determine which scenario you're facing.

Check the error details to identify your scenario:

HTTP StatusError MessageScenario
400 Bad Request"key was not present in the dictionary"Missing Lookup Reference
412 Precondition Failed"matching key values already exists"Alternate Key Duplicate
Various"Cannot insert duplicate key"Platform Duplicate Constraint


Scenario 1: Missing Lookup Reference


  • Status Code: 400 Bad Request
  • Error Message: "The given key was not present in the dictionary"
  • What happened: You're trying to reference a record (in a lookup field) that doesn't exist in Dynamics 365.


Example: { "name": "New Contact", "parentcustomerid@odata.bind": "/accounts(00000000-0000-0000-0000-000000000000)" } where the account with that GUID does not exist in D365 Sales.

Common Causes - Scenario 1

  • Lookup GUID is hardcoded incorrectly in your mapping.
  • Source system has outdated GUIDs that were deleted in D365.
  • Sync order issue: Child records syncing before parent records.
  • Security permissions: Service account can't see the lookup record.
  • Different business unit: Record exists but in a BU the user can't access.


Scenario 2: Duplicate Alternate Key


Status Code: 412 Precondition Failed
Error Message: "A record with matching key values already exists"
What happened: You're trying to CREATE a new record, but a record with the same alternate key value(s) already exists in D365.

Common Causes - Scenario 2

  • Re-syncing the same record from source system.
  • Source system sends updates as new records.
  • Sync running multiple times on the same data.
  • Using CREATE instead of UPSERT for transactional data.
  • Alternate key defined but sync flow doesn't account for it.

Scenario 3: Platform Duplicate Key


Status Code: Various
Error Message: "Cannot insert duplicate key"
What happened: You're trying to create a record that violates a platform-enforced unique constraint on the database table itself.

Common Causes - Scenario 3

  • Syncing the same price list multiple times without checking existence.
  • Source system sends full price list instead of just changes.
  • Multiple integrations creating prices for the same products.
  • Manual prices created in D365 that conflict with sync.
  • UOM conversions creating duplicate entries with same base UOM.