While working with Dynamics CRM web api we may get different exceptions. I have compiled list of common error and their resolution based on my experience working on recent projects
Error – An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.
POST – https://CRMORG.api.crm.dynamics.com/api/data/v9.1/leads
{
"firstname": "Jenny",
"lastname": "Paris",
"emailaddress1":"jennyparis@gmail.com",
"address1_telephone1":"(123)4567890",
"purchasetimeframe": 2,
"new_referredby":null,
"descriptionn":"Test Quick Create Lead"
}
Resolution
Most of the times this error will come because of mismatch in field schema name. If you look at above request body “descriptionn
” field schema name is incorrect. It should be “description
” instead of “descriptionn
”
It is always recommended to get the schema name from Customize the system->Entity->Lead->Fields->Schema Name
Another way to avoid this error is to use Rest Builder tool to generate API code
Error –An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property ‘objectid’ 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
POST – https://CRMORG.api.crm.dynamics.com/api/data/v9.1/annotations
{
"subject":"ABCDDDDDDDDDDDDd",
"notetext":"Test Details\n\n",
"filename":"File.txt",
"objectid@odata.bind" : "/contacts(f1c641eb-8c6a-ea11-a812-000d3a30f195)"
}
Resolution
This error will come while setting lookup field which is of multiple entity type. For example Regarding field on Activity, Notes and Activity party fields.
If you look at the request body “objectid@odata.bind
” field, Entity name is missing from schema name and CRM Odata web service confused at to what entity to be set in Regarding field in Notes.
Correct way to set thsi type of field to specify Entity name along with field schema like below.
“objectid_contact@odata.bind” : “/contacts(f1c641eb-8c6a-ea11-a812-000d3a30f195)”
Error – An error occurred while validating input parameters: Microsoft.OData.ODataException: Cannot convert the literal ‘2016/09/28’ to the expected type ‘Edm.Date’. > System.FormatException: String ‘2016/09/28’ was not recognized as a valid Edm.Date
POST – https://CRMORG.api.crm.dynamics.com/api/data/v9.1/leads
{
"firstname": "Jenny",
"lastname": "Paris",
"emailaddress1":"jennyparis@gmail.com",
"address1_telephone1":"(123)4567890",
"purchasetimeframe": 2,
"new_referredby":null,
"description":"Test Quick Create Lead",
"new_birthday":"2016/09/28"
}
Resolution
To avoid this error Date should be entered in below format. Web api accespts below format only for date only field.
“new_birthday”:”2016-09-28″
Error – 401 Unauthorized
Resolution
Check Application Registered in Azure has CRM online permission added in API permission. Application user created in CRM with Application ID from Azure AD, Also atleast one security role assigned to this user in CRM.
Find hereStep by step guide to register Application in Azure AD to be used to Web API.
Error –A validation error occurred. The value of ‘purchasetimeframe’ on record of type ‘lead’ is outside the valid range.
POST – https://CRMORG.api.crm.dynamics.com/api/data/v9.1/leads
{
"firstname": "Jenny",
"lastname": "Paris",
"emailaddress1":"jennyparis@gmail.com",
"address1_telephone1":"(123)4567890",
"purchasetimeframe": 20,
"new_referredby":null,
"description":"Test Quick Create Lead",
"new_birthday":"2016-09-28"
}>/code>
Resolution
Option set field value is incorrect. To fix this issue provide correct Option set field “purchasetimeframe
” Integer value from Customize the system->Entity->Lead->Field.
Hope this helps!
One thought on “Dynamics CRM 365 WEB API Common Errors and Resolution”