web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Confusion about Dynamics 365 Business Central API and accessing Purchase Orders

(0) ShareShare
ReportReport
Posted on by

So I am suffering from a great deal of confusion in regards to the Dynamics 365 API.

I have managed to authenticate to our instance using OUATH2 and have used to token to get stuff like a company list using the following:

api.businesscentral.dynamics.com/.../companies

Yet, when I try to access other elements, there seem to be no end to the cryptic errors that are returned by the server, and there seems to be no end to the rabbit hole that one needs to crawl through in order to figure things out. More specifically, the end points of the form show above do not seem to be available through the dynamics "Web Services" configurations page which instead shows only Odata4, Odata, and SOAP URLs.

So here are some questions:

1 - Is there a standard way to map an OData4 end point to (what seems to me to be) a more 'standard' endpoint. For the example shown above, the OData4 endpoint is of the form:

`api.businesscentral.dynamics.com/.../Company`

which returns data fine. Are all the elements exposed to the API available through the Web Services via an OData4 endpoint also available through a 'standard' end point?

2 - How does one determine what the required keys for a particular end point happen to be? My sticking point right now is that I can find Purchaes Orders using the OData4 endpoint, but I am unable to find the Purchase Order Line Items. After getting a list of Purchaes Orders, I try to find a list of the line items via the endpoint:

api.businesscentral.dynamics.com/.../<TENAND ID>/Production/ODataV4/Company('COMPANY_ID')/purchaseOrderLines

but the error returned is something "error in query syntax" (OK, I'll accept that) when i try to pass the "No." value of the PurchaseOrder as a parameter, or "Data required by the API was not set up. To set up the data, invoke the action from the API Setup page" when I use a pluralized endpoint. So, WHAT IS THE CONVENTION? When are these Odata4 endpoints plural, when are they singular? How do I find out what are, how many, and the order of the keys that are needed to get the item?

3 - Do I need to expose something else? How do I go about doing these things even though it already seems like the elements are already exposed? I've seen errors such as:

A node of type 'StartObject' was read from the JSON reader when trying to read the contents of the property 'PurchaseOrderPurchLines'; however, a 'StartArray' node was expected

or,

The data required by APi was not set up. To set up the data, invoke the action from the API Setup page.

or,

The property 'PurchaseOrderLines' does not exist on type 'NAV.PurchaseOrder'. Make sure to only use property names that are defined by the type

The last one was interesting as I was trying to do a post of a PurchaseOrder and was also including nested Line Items in the payload. What gives here?

4 - What's the best approach to accessing things? Is it preferable to use 'standard' endpoints, or should i be battling with the OData4 endpoints, which although indicated in the web services configuration, don't seem to respond well.

5 - Why is this thing so damned cryptic? Is it just me, or is has this been made purposefully obtuse? The 'documentation' seems weak.

I have the same question (0)
  • Verified answer
    Marco Mels Profile Picture
    on at
    RE: Confusion about Dynamics 365 Business Central API and accessing Purchase Orders

    Hello,

    Thank you for sharing the final outcome of the support ticket. This will help others.

    Great work!

  • Suggested answer
    jjku Profile Picture
    on at
    RE: Confusion about Dynamics 365 Business Central API and accessing Purchase Orders

    After much going back and forth, seems like the fix was easy.

    In order to integrate PO lines using APIv2, please  navigate to  "API Setup" page and invoke action "Fix Purchase Order API Records". This will generate all records for the Purchase Order API, please wait for it to finish. After that you should be able to use purchaseOrders endpoint.

  • jjku Profile Picture
    on at
    RE: Confusion about Dynamics 365 Business Central API and accessing Purchase Orders

    OK. Ticket submitted. Thanks for your help.

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Confusion about Dynamics 365 Business Central API and accessing Purchase Orders

    Hello,

    Feel free to raise a support request via your partner or CSP so we can assist you directly.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,857

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 2,687 Super User 2025 Season 2

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,203

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans