Forum Discussion

aTChris's avatar
aTChris
Resolver I
1 year ago
Solved

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 b...
  • aTChris's avatar
    1 year ago

    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],