Creating a project, adding libraries, and generating an OData service proxy

Once you are done with the application registration process and have collected all the necessary details, you are ready to create your client application. In this example, we will create a console C# application so that we can interact with Dynamics 365 for Finance and Operations OData services. The following steps describe how to create the client application:

  1. Create the C# console application: To start, use Visual Studio to create a C# console project.
  1. Add reference libraries: To authenticate and consume Finance and Operations OData services, you need at least the following two library packages. You can use the NuGet package manager in Visual Studio to install these libraries in your project and add references:
    • Microsoft.IdentityModel.Clients.ActiveDirectory: This package contains the binaries of the Active Directory Authentication Library (ADAL). ADAL provides a .NET standard class library with easy to use authentication functionality for your .NET client.
    • Microsoft.OData.Client: This library provides a LINQ-enabled client API for issuing OData queries and consuming OData JSON payloads.
  2. Add OData v4 client code generator: This is the Visual Studio extension from Microsoft and is used to generate OData entity proxy classes for your OData entities. If you do not have this extension already installed, you can download and install this template from the Visual Studio Marketplace. After you've downloaded and installed the tool, you can add the OData client to the project. This will create a file with an extension of tt (text template). Then, you need to update the MetadataDocumentUri string value in the tt file to your OData metadata endpoint. The following diagram illustrates the steps that you need to take to add the OData Client's tt file and update MetadataDocumentURI in Visual Studio:

Once the metadata endpoint URL has been updated, right-click on the tt file and choose to Run custom tool. This will read the metadata and build proxy classes for all the OData services. This step generates a library that contains all your OData services and their operations with names such as <YourProjectNameSpace>.Microsoft.Dynamics.DataEntities

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.104.214