Retrieve all dimensionSetLines for all SalesOrders

155 views Asked by At

Is it possible to retrieve dimensionSetLines for all SalesOrders in one request using Business Central API. Not just retrieve dimensionSetLines for a specific SalesOrder but for all of them.

I wanted to know if this is possible.

1

There are 1 answers

0
kaspermoerch On BEST ANSWER

You can't retrieve the Dimension Set Lines directly. You have to go through the parent i.e., the Sales Orders.

However you can still retrieve the required data in one API-call with some clever usage of the OData protocol:

  • $select to limit the number of fields retrieved for each Sales Order.
  • $expand to include the Dimension Set Lines in the call to the Sales Orders endpoint.

An example of the API call could be as follows (using REST Client in Visual Studio Code):

@auth = Bearer [Access Token]

GET https://api.businesscentral.dynamics.com/v2.0/[Tenant ID]/[Environment Name]/api/v2.0/salesOrders?$select=id,number&$expand=dimensionSetLines
Company: [Company Name]
Authorization: {{auth}}