What is “Does not support untyped value in non-open type” ODataException in creating records in D365 CE?

One of the most common errors we come across while calling API to create records in Dynamics but isn’t clear what it means? One such issue is – “An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.

On the console of the browser, you’ll see this –
consoleLoggedError

But, if you open the <objectName>.responseText of the Failure message of the call, you’ll see the below –

originalErrorA more zoomed view of the error would be below –

badRequest

This is because of my typo in the code [Which is the case for most scenarios] where you mistype a name of the field and neither does the error itself doesn’t specify which field you’re missing out on nor what it means!

Reason

This is because of a simple typo  in one of the fields in the object I was creating using AJAX

faultLine

In my case, this should have been “entity.duration” and not “entity.durationn“.

It was a simple issue which led me wander troubleshooting in areas which I shouldn’t look into.

Hope this saves you some valuable time! Happy 365ing!

Set Lookups in Xrm.WebApi D365 v9 correctly. Solving ‘Undeclared Property’ error

Using Xrm.WebApi needs you to be careful with the field names and what to use when. Especially, when you are dealing with Lookups.

One of the most common errors you’ll come across is the one like below – “An undeclared property (fieldname you entered) which only has property annotations in the payload but no property value was found in the payload.

error

This is confusing as to what needs to be put in while setting the lookup.

If you have done the below, entered the name of the field which is all in small caps  –

object[“msdyn_resourcerequirement@odata.bind”] = “/msdyn_resourcerequirements(<Guid>)”;

This will result in the above error!!!

 

You’ll need to put the Schema name of the lookup field instead and this should solve your problem –

correctName.png

and the code should look like this –

object[“msdyn_ResourceRequirement@odata.bind”] = “/msdyn_resourcerequirements(<Guid>)”;

And this should totally work for you!!

Hope this helps! 🙂