Forum Discussion

CMoerchen's avatar
CMoerchen
New Member
1 year ago
Solved

REST API with User Authentication Connection Issue

Hello! I had been struggling to make a connection with a REST API that also requires user authentication (for reference, Epicor) in Power BI Desktop. I eventually found a messy solution by using a query that hardcodes the API key and valid user credentials in the headers, and passes it to Web.Contents (which is not ideal, so if anyone has any other ideas please let me know!). For authentication, I'm using anonymous.

 

This is the structure:

= let url = "", username = "", password = "", apiKey = "", encodedCredentials = Binary.ToText(Text.ToBinary(username & ":" & password), BinaryEncoding.Base64), headers = [#"Authorization" = "Basic " & encodedCredentials, #"X-API-Key" = apiKey], source = Json.Document(Web.Contents(url, [Headers=headers])) in source

 

Where I'm stuck now is that when I view the published report in Power BI Service, it's not allowing me to refresh since it's saying the credentials are invalid. Is there something else I should try? I'm mostly not sure why it works in desktop and not on the web version.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi CMoerchen,

     

    Thank you for reaching out to Microsoft Fabric Community Forum.

     

    Power BI Service requires fixed base URLs when using Anonymous authentication with custom headers. Your current scenario likely uses a dynamic url string, which Power BI blocks in the cloud.

     

    Go to Dataset Settings > Set the credential method to "Anonymous".

    Ensure that BaseUrl is listed as the data source.

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!


    Regards,
    Vinay Pabbu

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi CMoerchen,

     

    Thank you for reaching out to Microsoft Fabric Community Forum.

     

    Power BI Service requires fixed base URLs when using Anonymous authentication with custom headers. Your current scenario likely uses a dynamic url string, which Power BI blocks in the cloud.

     

    Go to Dataset Settings > Set the credential method to "Anonymous".

    Ensure that BaseUrl is listed as the data source.

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!


    Regards,
    Vinay Pabbu

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi CMoerchen,

     

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Vinay Pabbu

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi @CMoerchen,

       

      As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
      If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

       

      Regards,
      Vinay Pabbu

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi @CMoerchen,

         

        As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
        If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

         

        Regards,
        Vinay Pabbu