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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
aTChris
Resolver I
Resolver I

All models within a workspace using the same credentials

I have created and published 5 reports within a workspace. Each report is almost the clone of the other with the differnce being the credneitals of the API. The SaaS platform we query distinguishes between each customers by credentials. This should allow me to query all 5 customers and display the summary titles on a dashboard.

 

However when I set the credentials for one customer in the workplace these are applied to all models within that workplace.... im assuming because the API URL is the same.

 

Im setting the privacy to org so that other users can see the data although I dont think that is related.

 

Can anyone think of a way that I can keep the creds unique per model when the API URL is the same.

1 ACCEPTED SOLUTION
aTChris
Resolver I
Resolver I

I think I found a solution. I dont like the fact I have to make credentials visible in the code but it works in PBID and the app service.

 

let
    // Your username and password
    Username = BasicAuthUsername,
    Password = BasicAuthPassword,
    
    // Encode the credentials
    Credentials = Binary.ToText(Text.ToBinary(Username & ":" & Password), BinaryEncoding.Base64),
    
    // URL of the web source
    SourceUrl = "https://www.example.co.uk",
    
    // Retrieve the data with authorization header
    Source = Json.Document(
        Web.Contents(SourceUrl, [
            Headers = [Authorization = "Basic " & Credentials]
        ])
    ),
    // Retrieve the data with authorization header
    Records = Source[Records],

View solution in original post

3 REPLIES 3
aTChris
Resolver I
Resolver I

I think I found a solution. I dont like the fact I have to make credentials visible in the code but it works in PBID and the app service.

 

let
    // Your username and password
    Username = BasicAuthUsername,
    Password = BasicAuthPassword,
    
    // Encode the credentials
    Credentials = Binary.ToText(Text.ToBinary(Username & ":" & Password), BinaryEncoding.Base64),
    
    // URL of the web source
    SourceUrl = "https://www.example.co.uk",
    
    // Retrieve the data with authorization header
    Source = Json.Document(
        Web.Contents(SourceUrl, [
            Headers = [Authorization = "Basic " & Credentials]
        ])
    ),
    // Retrieve the data with authorization header
    Records = Source[Records],
aTChris
Resolver I
Resolver I

It certainly appears that is the issue. Im now having to look at how to pass the creds within the file as a param.

I would say this is a shortcoming of the platform. Credentials should be report or model specific not workspace. We can see they thought of this in PowerBI Desktop considering these options and I am sure it used to work but I expect the by product of another idea has caused this issue.

CleanShot 2024-08-29 at 16.01.35.png

ibarrau
Super User
Super User

Hi. Unless you can get all the data with a single credential and then filter by customer at Power Query, I don't think you can make it with "just PowerBi". Like you are saying, Power Bi stores data sources in order to make it easy for refreshes and developers. If you have a data source with an address and type, it stores the credential for that specific one to replicate it each time you use it.

You might need to add another layer to your proyect. Like a database, datalake or warehouse. That can help you storing the data from an ETL or code tool that can get the data from the API. For example, writing a notebook that runs the api for each credential and the stores it on the storage. After that you could connect Power Bi.

I hope that helps,


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

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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