Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 64797

CRM Web API Preview – Generate Strongly Typed Objects from Metadata Document

$
0
0

The CRM Web API Preview is nicely documented but I am missing an article explaining how to generate strongly typed objects from the metadata document to use with server side code. The following walkthrough describe just that:

1. Enable Web API Developer Previewunder Settings –> Administration –> System Settings –> Previews and click ‘OK’
 Enable Web API Developer Preview

2. Download the MetaData document: Navigate to the Metadata document URL ([organization URI]/api/data/$metadata) with your browser. You should get an XML file describing your Organization Metadata.

To download, save (Ctrl+S in Chrome) the file to any directory you wish.

Metadata document

3. Install OData v4 Client Code Generator VS Extension in Visual Studio and Restart Visual Studio

Install OData v4 Client Code Generator VS Extension in Visual Studio

4. Add OData Client item to your VS project

image

5. Edit the newly created OData file, insert the Metadata file location (step 2) as the MetadataDocumentUri  constant value and save the file.
The OData v4 Client Code Generator should automatically generate a .cs file with strongly typed objects to match the Metadata document.

The OData v4 Client Code Generator setting

generated classes

6. Consume the newly created classes in your code

Consume generated class


Viewing all articles
Browse latest Browse all 64797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>