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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Dataflows asks for credentials for each URL

I am trying to implement a API call as a function in a dataflow. The issue is that the URL is created based on different IDs in a column and for each new ID the data flow asks for credentials. Why can't this be set on a higher level of the URL? Any workarounds? 

I fetch the input values from one API to be used in another API call in Business Central. 
regards

Johan

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I did actually solve it after I knew what to search for.
This is the M-code that did require a authentication validation for each combination in the url (I wanted anonymous):

  varApiName = "salesOrders?$expand=salesOrderLines",
  varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/" & varApiName ,
  varOptions = [Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],
  apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),

and this is the solution that prevented it:

  varApiName = "salesOrders?$expand=salesOrderLines",
  varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/",
  varOptions = [RelativePath=varApiName, Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],
  apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),
 
The changes are in bold.

View solution in original post

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft Employee

In your Data Source Settings, you should have a pull down to choose the root url instead of each detailed one.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

In dataflow there is no option:

Joohan_0-1634189989703.png

It is in Swedish but I guess you get the idea.

KNP
Super User
Super User

I don't do a lot with APIs but this ducumentation looks pretty detailed if you haven't seen it already.

https://docs.microsoft.com/en-us/power-query/handlingauthentication

 

I'd be surprised if you can't do it at the base level.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
Anonymous
Not applicable

Great documentation! Thank you. I am a bit unsure whether it can help me (see reply above) but it definitely gave me some ideas on how to proceed.

Can you share your Power Query code (hide anything sensitive obviously), it might help get you an answer.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
Anonymous
Not applicable

I did actually solve it after I knew what to search for.
This is the M-code that did require a authentication validation for each combination in the url (I wanted anonymous):

  varApiName = "salesOrders?$expand=salesOrderLines",
  varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/" & varApiName ,
  varOptions = [Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],
  apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),

and this is the solution that prevented it:

  varApiName = "salesOrders?$expand=salesOrderLines",
  varApiUrl = "https://api.businesscentral.dynamics.com/v2.0/" & TenantName & "/" & Instance & "/api/v2.0/companies(" & Company & ")/",
  varOptions = [RelativePath=varApiName, Headers=[ApiKeyName= TokenName , #"Authorization"="Bearer " & List.First(GetToken), #"DataAccessIntent" = "ReadOnly" ]],
  apidata = Json.Document(Web.Contents(varApiUrl , varOptions)),
 
The changes are in bold.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.