1

I am trying to create an entity in Dynamics CRM online with a custom lookup field. Even after providing the SchemaName(sg_DepartmentalProjectId) as mentioned here 'An undeclared property' when trying to create record via Web API I am still getting the same error.

An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'sg_DepartmentalProjectId' 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.

Below is my JSON Post

{
   "sg_invoicenumber": "SIAIR402742-416805",
   "sg_accountnumber": "5400",
   "sg_description": "xxxx",
   "sg_fy": "20",
   "sg_name": "Operational Journal: yyy - 09/20/2019",
   "sg_departmentid": "CC10530",
   "sg_postingdate": "2019-09-20",
   "sg_invoicedate": "2019-09-20",
   "sg_checkdate": "2019-09-20",
   "sg_paidfulldate": "2019-09-24",
   "sg_amount": 5597.4,
   "sg_effectivedate": "2019-09-20",
   "sg_DepartmentalProjectId@odata.bind":"/sg_departmentalmatters(e9c31cec-deff-e411-80c5-0050569732ae)"            
}
Dada
  • 6,313
  • 7
  • 24
  • 43
hpandalai
  • 438
  • 2
  • 13
  • 31

3 Answers3

4

Please Download Odata Metadata from the Developer resources & verify the exact casing. Jason Lattimer also confirmed that the bug while investigating the CRM REST builder issue:

I've come to figure out the metadata is in fact not the source of truth - it's the CSDL

I know it's super annoying when this is working different & getting solved by different solutions. Make sure you verify in all these places for the custom lookup attribute.

Microsoft reference: CSDL $metadata document

  • 1
    Below is how I see on Odata Metadata . Which one would I use? – hpandalai Sep 30 '19 at 20:45
  • 1
    @hpandalai Name = “sg_departmentalprojectid” – Arun Vinoth-Precog Tech - MVP Sep 30 '19 at 20:48
  • Thanks Arun. That was it. – hpandalai Sep 30 '19 at 21:03
  • Just stumbled upon the same error and cause of it. My property name wasn't wrong in relation to the "Schema" name when looking at the entity's fields, so that solution is universal. This however seems to be a more general solution. Also, an alternative way of finding the "associatednavigationproperty" is with the "Levelup for Dynamics" extension for Chrome/Firefox/Edge and looking at an entity through the "All Fields" feature: https://github.com/rajyraman/Levelup-for-Dynamics-CRM – Olov Dec 29 '20 at 09:04
1

I had the same problem, but in my case using the schema name didn’t work. I believe it’s because my field is setup as a navigation property to either of two different entities. I found the correct name by pulling the metadata for the entity from the API and looking at the navigation properties. There were two navigation properties defined for this field, one for each target entity, so I had to use the name of the correct one in my payload.

<NavigationProperty
        Name="parentcustomerid_account"
        Type="mscrm.account"
        Nullable="false"
        Partner="contact_customer_accounts">
    <ReferentialConstraint
            Property="_parentcustomerid_value"
            ReferencedProperty="accountid" />
</NavigationProperty>

The correct value was parentcustomerid_account above.

Sean
  • 1,416
  • 19
  • 51
1

I had same issue JSON:

{
    "activityid": "cbf73794-9e42-ec11-8c62-00224815945f",
    "subject": "Test 22",
    "new_AppointmentTypeId@odata.bind": "new_tasktypes(a97ec3cf-3e1a-ea11-a811-000d3a799417)"
}

Error I was getting:

An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_AppointmentTypeId' 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.

Resolution:

Use Metadata Browser https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/browse-your-metadata?view=op-9-1

Find ReferencingEntityNavigationProperty from Metadata Browser for fields you need it.

enter image description here

Working JSON:

{
    "activityid": "cbf73794-9e42-ec11-8c62-00224815945f",
    "subject": "Test 22",
    "new_AppointmentTypeId_Appointment@odata.bind": "new_tasktypes(a97ec3cf-3e1a-ea11-a811-000d3a799417)"
}
Debargha Roy
  • 2,320
  • 1
  • 15
  • 34
  • Thank you! - After much searching, this is what let me find the proper name to use for parentbundleidref lookup on quotedetail entity. – Beyro Sep 22 '22 at 21:54