Dynamics 365 finance and operations ODATA consuming - Length cannot be less than zero
Contents
When you consume a custom data entity, you get an error
Failure
errorSystem.ArgumentOutOfRangeException : Length cannot be less than zero” and it works fine for standard data entities.
The reason is the temporary XML file where the metadata stored which mismatches with the metadata from https://<yourenvironment>.cloudax.dynamics.com/data/$metadata
You can follow this post to understand how to create the XML file.
If you try to regenerate the metadata by saving the ODataClient.tt file, the XML will be accumulated, and the error keeps happening. The resolution here is simply delete it and regenerate metadata again by saving the ODataClient.tt file
Thank you for reading.