Skip to content
  • View menu
  • View sidebar

YanivRDT

Microsoft Dynamics CRM & Stuff

  • Home
  • About
Follow YanivRDT on WordPress.com

Blog Stats

  • 46,723 hits

Tag / strong

September 27, 2015 by yanivrdt

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

  • Uncategorized
  • class, CRM Web API Preview, generate, metadata, strong, type
  • 5 Comments

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 Preview under 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

Advertisement
Create a free website or blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • YanivRDT
    • Join 42 other followers
    • Already have a WordPress.com account? Log in now.
    • YanivRDT
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar