An undeclared property ”{FieldName}” which only has property annotations in the payload but no property value was found in the payload

Problem

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


Solution

After digging in the field itself, I remembered that it is configured to allow 2 types of records, these are:

  1. Accounts
  2. Contacts

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:

NOTE: <Guid > had an actual GUID but for sharing purposes I changed it to a constant.

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:

“_account” was added after the field name so it specifies that the field set in the lookup will point to accounts.

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s