Search code examples
dynamics-crmdynamics-crm-onlinedynamics-365dynamics-crm-webapi

Undeclared property when creating a record via Web API In Dynamics CRM Online


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",
   "[email protected]":"/sg_departmentalmatters(e9c31cec-deff-e411-80c5-0050569732ae)"            
}

Solution

  • 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