Today while using the Web Api to update “Account Name” lookup field of a contact I started to get the error below:
“An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property ‘parentcustomerid’ which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserialize
After digging in the field itself, I remembered that it is configured to allow 2 types of records, these are:
This made me think that probably we need to be more specific on the way we declarate the field metadata in our web api call. Originally it was set like this:
After an investigation, I found that it shoud point to the entity you want to set, in my case I wanted to save an Account so it had to be changed like this:
Same will happen if you want to set a Contact, you will just need to change the values so it point to the Contact entity:
Hope it helps.