Publishing and Consuming OData Endpoints in Business Central Online

When I first started integrating Microsoft Dynamics 365 Business Central with Excel, Power BI, and other tools, I was surprised by how little practical documentation there was on exposing existing pages as OData web services. Most articles focus on API pages or AL development, but if all you need is to expose a standard page like Vendor Ledger Entries or General Ledger Entries, the process is much simpler.

This guide walks through the complete process, along with a troubleshooting section covering an issue that took several hours to diagnose.


Publishing an OData Web Service

Business Central allows any published Page or Query object to be exposed through an OData endpoint.

Navigate to:

Search → Web Services

Create a new line:

Field Value
Object Type Page
Object ID (Page ID)
Service Name Your preferred endpoint name
Published

For example:

Object Type Object ID Service Name
Page 20 General_Ledger_Entries
Page 29 Vendor_Ledger_Entries

Once published, the endpoint becomes immediately available through OData.


Finding the Page ID

The easiest way to determine the Page ID is from the URL while viewing the page inside Business Central.

For example:

https://businesscentral.dynamics.com/<tenant>/Production/?company=AM60%20Property%20Trust&page=20

The important part is:

page=20

meaning the object is Page 20.

Another example:

https://businesscentral.dynamics.com/<tenant>/Production/?company=AM60%20Property%20Trust&page=29

Here,

page=29

corresponds to Vendor Ledger Entries.

This works for most standard pages throughout Business Central.


Constructing the OData URL

The endpoint format is:

https://api.businesscentral.dynamics.com/v2.0/<tenant>/<environment>/ODataV4/Company('<company>')/<service-name>

Example:

https://api.businesscentral.dynamics.com/v2.0/e7509dc1-fefb-4789-8563-7df05946f26e/Production/ODataV4/Company('AM60%20Property%20Trust')/Vendor_Ledger_Entries

Notice that the endpoint uses the Service Name, not the page name or page ID.


Connecting from Excel

In Excel:

Data
→ Get Data
→ From Other Sources
→ From OData Feed

Enter the endpoint URL.

When prompted for authentication:

  • Choose Organizational Account
  • Sign in using your Microsoft 365 account

Business Central Online no longer supports Web Service Access Keys, so OAuth authentication is required.


Connecting from Power BI

Power BI uses the same OData endpoint.

let
    Source =
        OData.Feed(
            "https://api.businesscentral.dynamics.com/v2.0/<tenant>/<environment>/ODataV4/Company('AM60%20Property%20Trust')/Vendor_Ledger_Entries",
            null,
            [Implementation="2.0"]
        )
in
    Source

The same M query also works in Excel.


Troubleshooting

“The odata.context url is invalid”

One issue I encountered after publishing new web services was the following error in Excel:

DataFormat.Error:
The odata.context url
'https://.../$metadata#Company('ABC%20Company%20Inc')/GLEntriesTest'
is invalid

Interestingly:

  • Existing web services continued to work.
  • Newly published web services failed.
  • Power BI loaded the same endpoints successfully.
  • Excel Online also loaded the same endpoints successfully.

Initially this looked like a Business Central problem, but after a lengthy investigation, the issue turned out to be on the Excel side.

Resolution

Clearing permissions from Excel’s main Data Source Settings was not sufficient.

The issue was resolved by:

  1. Opening Power Query Editor.
  2. Opening Data Source Settings from within the editor.
  3. Clearing the Business Central data source permissions.
  4. Reauthenticating using Organizational Account.

After doing this, the newly published web services loaded correctly.

If you encounter the same error after publishing new OData services, this should be one of the first things you try before assuming there’s an issue with Business Central.


A Few Practical Tips

  • Use descriptive service names. These become part of the URL and make integrations easier to understand.
  • Prefer exposing only the pages you actually need instead of publishing everything.
  • If you’re building reports in Power BI, the same endpoints can usually be reused in Excel and other OData consumers.
  • If a newly published service doesn’t load in Excel but works elsewhere, clear the Power Query data source permissions before spending hours debugging Business Central.

Publishing standard Business Central pages as OData web services is surprisingly straightforward once you know where to look. Hopefully this saves someone else the several hours of troubleshooting it took me to discover that the problem wasn’t the endpoint at all—it was a stale Power Query cache.

Leave a Reply

Your email address will not be published. Required fields are marked *