A developer creates a contact through the Dataverse Web API and tries to set the parent account by including "[email protected]": "/account(1f8d2c4e-0000-0000-0000-000000000001)" in the body. The request returns 400 Bad Request. What is wrong?
Select an answer to reveal the explanation.
Short Explanation
An @odata.bind value is a URL, and URLs in the Web API use entity set names, which are usually plural. /account(...) isn't a real address you can bind to; /accounts(...) is. The navigation property name in the key is actually fine here.
Full Explanation
To associate a lookup when creating or updating a row through the Dataverse Web API, the body includes the single-valued navigation property name followed by @odata.bind, with a value that is the relative URI of the related row. That URI uses the related table's entity set name, which for account is accounts, followed by the key in parentheses. Using /account({id}) points to a resource that does not exist, so the service rejects the request with 400 Bad Request. The property name parentcustomerid_account is the correct navigation property for the account side of the polymorphic customer lookup on contact; the plain lookup logical name parentcustomerid is not a navigation property in this case, so switching to it would introduce a new error rather than fix this one. Associating through a separate request to the $ref endpoint is a valid alternative, but it is not required; @odata.bind in the create body is supported and is usually preferred because it is a single request. GUIDs are the standard key for @odata.bind values; alternate keys can also be used, but they are not required. Exam caveat: navigation property names for custom lookups are case-sensitive and follow the schema name, which is a common source of similar 400 errors. Operational check: resend the request with /accounts({id}), then retrieve the contact with $select=_parentcustomerid_value and confirm the account GUID is set.