Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Dataflow will only refresh in edit mode

 

SOLUTION
Separate base URL from relative path when using Web.Contents

---------------------------------------------------------------------------

I have a dataflow that fetches data from a REST POST API using an access token for authentication. I can fetch data when I'm editing the dataflow, but when I save and close it and try to update it I get this error message, which honestly doesn't give me much:

 

Error:  Request ID: b23d1f30-8b26-7f28-6431-d5d33ec7178b Activity ID: 39a5fc42-209f-48e5-adb6-cbf842c7e988

 

Here is the relevant part of the M:

 

 

 

 

  Source = Json.Document(
      Web.Contents("https://api.simplesat.io/api/v1/responses/search", 
        [
          Headers=[
            #"X-Simplesat-Token"=#"Simplesat Token",
            #"Content-Type"="application/json", 
            #"Accept-Encoding"="gzip,deflate"
          ], 
          Content=Text.ToBinary("")
        ]
      )
    )

 

 

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    Based on the information you have provided, the data stream appears to be able to successfully fetch data from the REST POST API while in edit mode, but encounters an error when attempting to refresh after saving and closing. There are several steps you can take to troubleshoot and possibly resolve this issue:

    1. Ensure that the Simplesat token used for authentication is still valid outside of edit mode. If the token has expired, authentication may fail.
    2. When using Web.Contents, it is recommended to separate the base URL from the relative path, especially when using dynamic data sources.
    3. Make sure that the data source settings in Power BI are set to use anonymous authentication since the authentication token is passed in the header.

    If you are still experiencing problems after trying these steps, please provide more detailed information about the following:

    • Whether the authentication token has specific expiration or usage constraints that may affect its validity outside of edit mode.
    • Any changes made to data source settings or M-code after the problem was discovered.

     

    Best Regards,

    Ada Wang

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

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    I was able to fetch some more info about the update:

    The credentials provided for the Web source are invalid. (Source at https://api.simplesat.io/api/v1/responses/search.)

    Aktivitets-ID:70954bee-4d5c-4b6d-93df-3585a17ca060
    Forespørsels-ID:089d5b6e-227a-c02d-e08b-28f72bd66378
    Statuskode:400
    Klokkeslett:Thu Mar 14 2024 10:17:14 GMT+0100 (sentraleuropeisk normaltid)
    Tjenesteversjon:13.0.22826.64
    Klientversjon:2403.1.18388-train
    Klynge-URI:https://wabi-north-europe-i-primary-redirect.analysis.windows.net/
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Based on the information you have provided, the data stream appears to be able to successfully fetch data from the REST POST API while in edit mode, but encounters an error when attempting to refresh after saving and closing. There are several steps you can take to troubleshoot and possibly resolve this issue:

    1. Ensure that the Simplesat token used for authentication is still valid outside of edit mode. If the token has expired, authentication may fail.
    2. When using Web.Contents, it is recommended to separate the base URL from the relative path, especially when using dynamic data sources.
    3. Make sure that the data source settings in Power BI are set to use anonymous authentication since the authentication token is passed in the header.

    If you are still experiencing problems after trying these steps, please provide more detailed information about the following:

    • Whether the authentication token has specific expiration or usage constraints that may affect its validity outside of edit mode.
    • Any changes made to data source settings or M-code after the problem was discovered.

     

    Best Regards,

    Ada Wang

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Ada

       

      Thank you for chipping in on this. 

       

      1. It is valid and working, both in edit mode i Power BI and through Postman
      2. I can give that a try
      3. They are anonymous and also skip the test connection as recommended by Simplesat (https://help.simplesat.io/en/articles/3459688-connect-power-bi-to-simplesat-api)

      If you look at the link above Simplesat says you should add the token as a parameter (in the dataset), but that is not possible to do in a dataflow.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I tested creating a report with the same query, published it to a workspace and updated the dataset. That worked fine. 

      The datasets have the parameter option in the settings, which isn't an available setting in a dataflow. I guess that's where the issue lies.. Any workaround?