MS Tech & Coffee

Thoughts of a .NET Developer turned into MS Dynamics architect turned into Power Platform Director turned into AI and Business Transformation Global Lead… all views are my own!

Hello team,

A very quick note to remind you about something really important when working with the Dynamics Web API, it is one of those things that you always forget to check until you spent 3 hours trying to figure out why it isn’t working.

I was updating my code to create some related records after creating  a contact record and in one of the related entities I got this error:

postmanerror

“An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property ‘YOUR FIELD’ 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.”

This is caused because in my request I had the wrong field name, please remember always use the schema name for the lookups!

contactinfo

It is quite common for different people to create the fields in an entity and as I am sure you know Dynamics 365 tends to keep the characters in Capitals when it maps the schema name:

myfieldinformation

Some people would correct this and leave the schema name to be: mif_myfield

Others will just leave it like that.

Personally I tend to correct it and leave everything lower case but whatever works for you.

So my issue with my request was that I was using the Name of the field rather than the Schema Name:

This is wrong:

incorrectrequest

This is correct:

correctrequest

Changed that to use the schema name and everything started working perfectly 😊

Thanks,

Mario

 

 

 

6 responses to “How to fix getting “Undeclared Property Error” when using Lookups with Dynamics 365 Web API”

  1. priyeshwagh777 Avatar

    Hi,
    In my case, I’m struggling to associate a Price List with the created Order record. I’m using the below. Is this correct?

    dataObject[“_pricelevelid_value@odata.bind”] = “/pricelevels(” + priceListValue + “)”;

    1. Mario Trueba Cantero Avatar

      Hello Priyesh,

      You can’t directly update the value objects. Something like this should work:
      dataObject[“pricelevelid@odata.bind”] = pricelevels(pricelevelid);

      The first pricelevelid is the lookup field name, the second one is the Guid

      Let me know how it goes!

      Thanks,

      Mario

  2. Kaloyan Pehlivanov Avatar
    Kaloyan Pehlivanov

    Hi Mario,

    I have the same issue when I try to update any lookup of an activity entity. Is there anything other I need to add for lookups on activities or is it a bug?

    I have no problem updating partylist fields on activities.
    I have no problem updating lookups on any normal entity(custom and oob).
    Even tried using CRM REST Builder. but I get the same error.

    Regards,
    Kaloyan

  3. Alan Hummel Avatar
    Alan Hummel

    Thank you so much for posting this! I’m new to Dynamics CRM and its API, and was stuck on updating a relationship via an API call. This post was exactly what I needed to correct my problem and get my Monday off to a good start. Thank you!

    1. Mario Trueba Cantero Avatar

      Welcome to Dynamics!! Happy to help!! Have a great rest of the week!

  4. Prema Arya Avatar
    Prema Arya

    Thanks for posting this, it helped me and saved me lot of time :).

Leave a reply to Mario Trueba Cantero Cancel reply

I’m Mario

Welcome to MS Tech & Coffee, a project I started more than 8 years ago as a place where I could drop things that I was encountering in my journey as .NET developer in the UK. That journey has taken me to many places and now looking back I want to use this project to share some of my personal views on technology, AI, the Microsoft ecosystem and of course.. a bit of coffee!

Let’s connect