Creating an ODataClient for MsDyn365FO

I recently had the task to create an ODataClient for Microsoft Dynamics 365 for Finance and Operation. Because I faced some challenge, I want to share with you a step by step guide on how to create an ODataClient for MsDyn365FO. 

Before I started my first try on the ODataClient, I found the following information:

 Before you begin, you have to install the Visual Studio extension “OData Client Code Generator”. After the successful installation you will find the new item OData client in the “Add New Item” dialog. After adding such an item you have to open the *.tt file and set the TempFilePath to something like “C:/Tmp/metaTemp.xml” because the processing will have to deal with a big metadata file. Even though the comments in the template tells you that it is possible to use the metadata URL directly in the template, I can tell you that this does not work with MsDyn365FO, because the metadata XML is simply too big. You will see errors like “Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals.”

Instead of directly using the URL of the metadata XML, I would save/download the metadata XML and use this file for the generation of the ODataClient. To do so open$metadata (https://<MsDyn365FO>/data/$metadata) and save the metadata XML with your browser. To use the saved file, change the value MetadataDocumentUri in the *.tt file to something like “File:///C:/Temp/metaProd.xml” and save it with Visual Studio. After a short processing time the ODataClient has been generated and is ready for building/compiling.

 To use the created ODataClient you can use the samples from the Dynamics-AX-Integration repository e. g. authentication via OAuth.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s