25.Feb.2023
Update Entity Navigation Property by Alternative Key with Dynamics 365 Web API
API Intergration
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
Go to Keys page and add new_city_code to Selected Attributes. Now you can use it on UI and API
Learn more about Navigation properties