Forum Discussion

kobia10's avatar
kobia10
Microsoft Employee
1 year ago
Solved

Web connector in powerapp dataflow returns error in refresh, but works well in design

I am connecting anonymously to a web site using the Web connector. (using Basic authentication - I have API Id and secrect to use as user and pwd - and providing these via the optional Options parameter of the Web connector)

When designing in the UX all works fine and  I can see data (it does not ask for credentials).

However, when refershing the power apps dataflow I get the error "The dataflow could not be refreshed because there was a problem with the data sources credentials or configuration. Please update the connection credentials and configuration and try again. Data sources"

  • That's tricky. I have not tested this outside of pbi service but may be worth a shot. It may not be possible with your data source, but if you specify the same query parameters in the first argument of Web.Contents as the query parameters you specify in the Query record of the optional record second argument, then you can trick the test connection that the service runs.

     

    Also described in a Chris Webb post: https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/

     

    Relevant excerpt:

     

    This technique will only work if the url passed to the first parameter of Web.Contents() is valid in itself, is accessible and does not return an error. But what if it isn’t? Luckily there’s another trick you can play: when you specify the Query option it can override parts of the url supplied in the first parameter. For example, take the following expression:

     

    Web.Contents(
     "https://data.gov.uk/api/3/action/package_search?q=apples",
     [Query=[q="oranges"]]
    )

     

    When static analysis is carried out before dataset refresh, the url

     

    https://data.gov.uk/api/3/action/package_search?q=apples

     

    ..is evaluated. However when the dataset is actually refreshed, the search term in the Query option overrides the search term in the base url, so that the call to the web service that is actually made and whose data is used by the query is:

     

    https://data.gov.uk/api/3/action/package_search?q=oranges

     

    This means you can specify a base url that isn’t really just a base url just so that static analysis succeeds, and then use the Query option to construct the url you really want to use.

7 Replies

  • Hi kobia10 Try re-entering the API credentials in the Dataflow’s Data Source Settings to ensure they match during both design and refresh and verify that the authentication method (Basic Auth) is correctly set up for both design and refresh also check for any network and service related issue it might be because of that also

    • kobia10's avatar
      kobia10
      Microsoft Employee

      In the connection settings I dont have a place to enter the additional credentials info. Either Anonymous (with no additional params) and. Org account 

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi kobia10,

         

        Thank you for reaching out to the Microsoft Fabric Forum Community.

         

        Here are the alternative methods:

        Use Power BI Dataflows
        Switching to Power BI Dataflows allows greater flexibility when connecting to authenticated web APIs. Power BI supports Basic Authentication, allows custom headers in Web.Contents, and offers the "Skip test connection" feature none of which are available in Power Apps Dataflows. This ensures your API credentials are handled securely and the dataflow can refresh successfully. Once the data is ingested, you can export it to Dataverse or make it available to Power Apps through a shared dataset or connected table.

         

        Create a Custom Connector
        If you need to stay within Power Apps and use the API regularly, creating a Custom Connector is a robust solution. It lets you securely define authentication (e.g., Basic, OAuth2), manage headers, and reuse the connector across apps and Power Automate flows. This approach is ideal for integrating secure APIs directly without relying on workarounds or intermediate services, and ensures consistent behavior across the Power Platform.

         

        If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.


        Thank you & Regards,
        Prasanna Kumar

    • kobia10's avatar
      kobia10
      Microsoft Employee

      Hi, I am using PowerApps dataflow where I dont have an option of skipping connection test

      • MarkLaf's avatar
        MarkLaf
        Super User

        That's tricky. I have not tested this outside of pbi service but may be worth a shot. It may not be possible with your data source, but if you specify the same query parameters in the first argument of Web.Contents as the query parameters you specify in the Query record of the optional record second argument, then you can trick the test connection that the service runs.

         

        Also described in a Chris Webb post: https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/

         

        Relevant excerpt:

         

        This technique will only work if the url passed to the first parameter of Web.Contents() is valid in itself, is accessible and does not return an error. But what if it isn’t? Luckily there’s another trick you can play: when you specify the Query option it can override parts of the url supplied in the first parameter. For example, take the following expression:

         

        Web.Contents(
         "https://data.gov.uk/api/3/action/package_search?q=apples",
         [Query=[q="oranges"]]
        )

         

        When static analysis is carried out before dataset refresh, the url

         

        https://data.gov.uk/api/3/action/package_search?q=apples

         

        ..is evaluated. However when the dataset is actually refreshed, the search term in the Query option overrides the search term in the base url, so that the call to the web service that is actually made and whose data is used by the query is:

         

        https://data.gov.uk/api/3/action/package_search?q=oranges

         

        This means you can specify a base url that isn’t really just a base url just so that static analysis succeeds, and then use the Query option to construct the url you really want to use.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kobia10,

     

     

    Thanks for reaching out to the Microsoft Fabric Forum Community.

     

    If the issue still persists, I’d recommend raising a support ticket with Microsoft. The support team can look into the backend and provide more in-depth assistance tailored to your environment.


    https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket


    If this helped, please mark the response as the accepted solution and give it a thumbs-up so others can benefit too.

    Best regards,
    Prasanna Kumar