How to Expose D365 Data through OData?

How to Expose D365 Data through OData?

This article covers answers following questions:

  1. What is OData?
  2. How to expose D365 data through OData?
  3. How to acheive OData connectivity with your D365 instance?
  4. How to test OData service endpoints with Postman?
  5. How to get D365 data in Postman using Client ID and Client Secret of an Azure App?

So, let's just dive in to the article.

Introduction:

OData is a standard protocol for creating and consuming data. The purpose of OData is to provide a protocol that is based on Representational State Transfer (REST) for create, read, update, and delete (CRUD) operations. OData applies web technologies such as HTTP and JavaScript Object Notation (JSON) to provide access to information from various programs. OData provides the following benefits:

  • It lets developers interact with data by using RESTful web services.
  • It provides a simple and uniform way to share data in a discoverable manner.
  • It enables broad integration across products.
  • It enables integration by using the HTTP protocol stack.

Supported features from the OData specification

  • CRUD support is handled through HTTP verb support for POST, PATCH, PUT, and DELETE.
  • Available query options are:$filter$count$orderby$skip$top$expand (only first-level expansion is supported)$select
  • The OData service supports serving driven paging with a maximum page size of 10,000.

Cross-company behavior

By default, OData returns only?data that belongs to the user's default company. To see data from outside the user's default company, specify the ?cross-company=true query option. This option will return data from all companies that the user has access to.

Example: https://[baseURI\]/data/FleetCustomers?cross-company=true

To filter by a particular company that isn't your default company, use the following syntax:

https://[baseURI\]/data/FleetCustomers?$filter=dataAreaId eq 'usrt'&cross-company=true

Exposing OData entities

OData entities are based on the concept of an updatable view. When the IsPublic property for an updatable view is set to TRUE, that view is exposed as a top-level OData entity.

OData URL Examples

[Your organization's root URL]/data =>List all the OData entity endpoints.

[Your organization's root URL]/data/Customers => List all the customers.

[Your organization's root URL]/data/Customers?$top=3 =>List the first three records.

All the above basic information about OData is taken from this article from Microsoft. You can read more details from there.

Get Data through OData:

To be able to get data from and Odata endpoint, we need to perform following steps to acheive the connectivity with D365 instance.

  1. Create an app in Azure portal.
  2. Create a user in AAD as well as in D365.
  3. Register the app in D365, created in step 1.


Create an app in Azure portal:

Search for App registration and click on the App Registration:


Click on new registration button:

Enter the name of app, select account type and then click on register button.

Copy Client ID

Click on Add a certificate or secret link to generate client secret:

Click on New client secret button:

Enter Description and Expiry Period and click on Add button

After the secret is created, copy client secret instantly as once the page is refreshed, you will not be able to copy this secret and then you to create a new secret.

Next click on Add Permission tab and then click Add a permission button:

Click on Dynamics ERP tile:

Click on Delegated permissions tile:

Select Odata.FullAccess checkbox:

Now click on Owners tab and you will find your account as owner. You can add here other owners as well, if you want a different user to access and use this App.

Now login into D365 instance.

And navigate to System Administration>Users>Users

Click on New button and add a new user.

In user previliges, you can assign System Administrater access.





要查看或添加评论,请登录

Muhammad Abbas的更多文章

社区洞察

其他会员也浏览了