Update Entity Navigation Property by Alternative Key with Dynamics 365 Web API

Update Entity Navigation Property by Alternative Key with Dynamics 365 Web API

To update (for create also) entity's navigation property with existing entity by Alternative Key you must set the value of single-valued navigation properties using the @odata.bind annotation.

PATCH [Organization URI]/api/data/v8.2/new_streets(00000000-0000-0000-0000-000000000000) HTTP/1.1 Content-Type: application/json; charset=utf-8 OData-MaxVersion: 4.0 OData-Version: 4.0 Accept: application/json {"new_City@odata.bind":"/new_cities(new_city_code='S1')"}

How to add Alternative Key to Lookup property?

First, create custom field which will hold feature value, as in example new_city_code 

Dynamics CRM custom field

Go to Keys page and add new_city_code  to Selected Attributes. Now you can use it on UI and API

Dynamics CRM Alternative key
 

Learn more about Navigation properties

About us

Do you need help in services integration? Contact us to start working for your project!

Read More

Are you looking for