Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
xembledev
Advocate I
Advocate I

Connecting to Dynamics 365 Business Central API v2.0

I am working on creating a dashboard using the official connector to BC. I was able to set the connection authentication and while exploring I can see all the endpoints being displayed effectively; so I can see the treeview with the API and Web service endpoints displayed and selectable. If I click on an endpoint like the "Sales Invoice" endpoint, the preview is loaded correctly, and if I import data, it will be brought up into Power BI.

 

xembledev_0-1639678166046.png

 

The problem comes when I try to use a different detail endpoint such as "Sales Invoice Lines" or any detailed endpoint in this fashion as "Purchase Order Lines" and the like. Error thrown is telling me that "You must specify an Id or a Document Id to get the lines".

 

xembledev_1-1639678260838.png

 

Now, I understand what the error is trying to tell me. If I inspect this API via Postman, and I add parameters to the GET request I am able to query the lines correctly. I am lost on how to get this interface to work from Power BI and load all related lines at once. So far I have only been able to get Sales via web service using OData V4.

 

Thank you in advance !

1 ACCEPTED SOLUTION
mortenseifert
Regular Visitor

Hi, I ran into the same problem this week. When you have loaded the salesInvoices you need to go to "Transform data".

 

Here you have two options. 

a) Create the product of the two tables, i.e. fields from the salesInvoice will be repeated for each salesInvoiceLine, or

b) Create a new table with the lines and create the relation your self

 

a) Create Cartesian Product

All the way to your right, youh have the related tables. Press the little "split" icon and select expand.

mortenseifert_2-1652951624834.png

 

b) New table

If you want to have the lines in it's own table, you need to do the following.

 

1. Right click the column with the table and select "Add as New Query"

mortenseifert_3-1652951692010.png

 

2. Select the new table choose the action "To Table" 

mortenseifert_4-1652951791221.png

mortenseifert_5-1652951809606.png

 

3. Now choose the "split" icon (as is option a) - this time uncheck "Use original column name as prefix"

mortenseifert_6-1652951857977.png

 

4. Close and Apply and create the relation between the two tables.

 

 

 

 

 

 

 

 

 

View solution in original post

8 REPLIES 8
mortenseifert
Regular Visitor

Hi, I ran into the same problem this week. When you have loaded the salesInvoices you need to go to "Transform data".

 

Here you have two options. 

a) Create the product of the two tables, i.e. fields from the salesInvoice will be repeated for each salesInvoiceLine, or

b) Create a new table with the lines and create the relation your self

 

a) Create Cartesian Product

All the way to your right, youh have the related tables. Press the little "split" icon and select expand.

mortenseifert_2-1652951624834.png

 

b) New table

If you want to have the lines in it's own table, you need to do the following.

 

1. Right click the column with the table and select "Add as New Query"

mortenseifert_3-1652951692010.png

 

2. Select the new table choose the action "To Table" 

mortenseifert_4-1652951791221.png

mortenseifert_5-1652951809606.png

 

3. Now choose the "split" icon (as is option a) - this time uncheck "Use original column name as prefix"

mortenseifert_6-1652951857977.png

 

4. Close and Apply and create the relation between the two tables.

 

 

 

 

 

 

 

 

 

@mortenseifert Thank you for your detailed explanation.

Glad I could help ✔

V-lianl-msft
Community Support
Community Support

Hi @xembledev ,

 

Power BI desktop asks for a Document ID.You can try to use the Http methods of the REST API’s to get the data

Please Enter your companies API URL with ID.For example: Your Endpoint + API URL +(ID).

https://ruudvg.com/2019/05/26/microsoft-business-central-api-beta-create-a-sales-order-and-sales-ord... 

https://yzhums.com/20690/ 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the reply. As detailed in my original post, I have used the Sales Invoice Lines HTTP GET endpoint via postman to retrieve just individual sales invoice line detail, and that is working as intended, no problem whatsoever.

 

What I do not understand is how is Power BI going to load all my sales invoice lines if this endpoint is asking me go individually (one by one) ? There is no endpoint (Get Operation) that can retrieve all "sales invoice lines" at once like there is for the plain "sales invoice" or like there is using OData.

Were you able to solve this issue? I'm having the same problem

Nope. The only way I made it work was using OData endpoints, this is, the old ones you can find on Business Central as "Web Services". In the newer API, you have different endpoints for Sales Quotes, Sales Invoices and Sales Orders; so instead, I had to use the old "Sales Documents" (which includes all these three mentioned so you have to filter or use $filter in odata).

Create a custom function to load Business Central sales order lines into Power BI.  See this article on how to do it: 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.