# D365 Finance and Operations OData URL Builder

> Source: https://netray.co/tools/d365-fo-odata-url-builder-for-ax-migration
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Generate the OData request and OAuth token call to read data entities from D365 F&O during an AX migration or validation.

## Category

microsoft-dynamics

## Erp

Dynamics 365 Finance and Operations

## Audience

- D365 developer
- Integration engineer
- Migration consultant

## Tool

**Kind:** template

**Output:** code

**Language:** http

**Fields:**

#### Environment host

**Key:** host

**Type:** text

**Default:** contoso-test.operations.dynamics.com

**Help:** Your F&O environment host name without https://.

#### Entra ID tenant ID or domain

**Key:** tenant

**Type:** text

**Default:** contoso.onmicrosoft.com

#### App registration client ID

**Key:** client_id

**Type:** text

**Default:** 00000000-0000-0000-0000-000000000000

#### Data entity

**Key:** entity

**Type:** select

**Options:**

- CustomersV3
- VendorsV2
- ReleasedProductsV2
- SalesOrderHeadersV2
- PurchaseOrderHeadersV2
- MainAccounts

**Default:** CustomersV3

#### Legal entity (dataAreaId)

**Key:** legal_entity

**Type:** text

**Default:** usmf

#### Fields to select

**Key:** select_fields

**Type:** text

**Default:** CustomerAccount,OrganizationName,CustomerGroupId

**Help:** Comma separated field names from the entity metadata.

#### Row limit ($top)

**Key:** top

**Type:** number

**Default:** 100

**Blocks:**

#### 1. Get an access token (client credentials)

**Body:** POST https://login.microsoftonline.com/{{tenant}}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id={{client_id}}&client_secret=<YOUR_SECRET>&scope=https://{{host}}/.default

#### 2. Read the entity for one legal entity

**Body:** GET https://{{host}}/data/{{entity}}?$filter=dataAreaId eq '{{legal_entity}}'&$select={{select_fields}}&$top={{top}}
Authorization: Bearer <ACCESS_TOKEN>
Accept: application/json

#### 3. Read across all legal entities

**Body:** GET https://{{host}}/data/{{entity}}?cross-company=true&$select=dataAreaId,{{select_fields}}&$top={{top}}
Authorization: Bearer <ACCESS_TOKEN>
Accept: application/json

#### 4. Count rows for a reconciliation

**Body:** GET https://{{host}}/data/{{entity}}/$count?cross-company=true
Authorization: Bearer <ACCESS_TOKEN>

**Notes:** The app registration must also be registered in D365 under System administration, Setup, Microsoft Entra ID applications, with a user mapped. Never paste a real client secret into shared documents. Space characters in URLs must be URL encoded by your client. Field names depend on your release; read /data/$metadata to confirm. OData is for small and medium reads, use the Data management framework or export to Azure for bulk.

## Content

**Intro:** During an AX 2012 to Dynamics 365 move you will repeatedly read D365 entities to validate loads. This builder writes the token request and the OData calls for single legal entity reads, cross-company reads and row counts.

**Sections:**

#### How to use the builder

**Body:** Fill in your environment host, tenant, app registration client ID, the entity and the legal entity. Copy the blocks into Postman, an HTTP file in VS Code or your own script. Request a token first, then use the token in the Authorization header of the data requests. Replace the secret and token placeholders locally; never store them in the tool.

**Bullets:**

- Start with a small $top to confirm connectivity
- Use $select to limit columns and reduce payload size
- Use cross-company=true only when you need several legal entities

#### How the calls work

**Body:** D365 F&O exposes data entities as OData v4 collections under /data. Authentication uses Microsoft Entra ID, and the client credentials flow is the usual pattern for services. The scope is the environment URL plus /.default. Data is scoped by legal entity through the dataAreaId field, and the cross-company query option removes the default scoping to the user's default company.

#### Using it for migration validation

**Body:** After each import, count rows in D365 with $count and compare to your AX source count per legal entity. Then sample key fields with $select and a filter on a few known records. This catches truncated loads, wrong legal entity mapping and missed dependencies before business users find them.

#### Common mistakes

**Body:** Users forget the cross-company option and see only their default company. Others exceed throttling by paging large reads through OData instead of using the Data management framework. A third frequent issue is a missing user mapping for the app registration, which returns an authorization error even with a valid token.

**Cta:** If you want automated validation between AX or GP and a new D365 environment, we can help build reconciliation jobs that run in your own tenant or on-prem.

**Faq:**

#### Does this work for Business Central?

**Answer:** No. Business Central uses a different API base (api.businesscentral.dynamics.com) and its own v2.0 endpoints. This builder targets Dynamics 365 Finance and Operations data entities under the /data path.

#### Why do I get a 401 or 403 with a valid token?

**Answer:** The app registration must be added in D365 under Microsoft Entra ID applications and mapped to a user with the right security roles. A token alone is not enough. Also check the scope matches your environment host exactly.

#### Is OData fine for large migrations?

**Answer:** It suits validation and small reads. For bulk import or export use the Data management framework, package APIs or export to Azure Data Lake. OData reads of millions of rows are slow and subject to throttling.

#### How do I find field names?

**Answer:** Request https://your-host/data/$metadata or browse the entity in Data management. Field names are case sensitive in OData, and some labels in the UI differ from the stored names.

## Search terms

d365 f&o odata url, dynamics 365 finance odata query, d365 data entity rest api, odata cross-company d365, d365 oauth client credentials, d365 customersv3 odata

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
