Forum Discussion

seann's avatar
seann
Frequent Visitor
8 years ago
Solved

404 error when loading data to model

I'm querying an API using http and am able to load and model the data in the query editor with no issues. When I click save and close, it begins to load to the model but then I receive a webcontents error 404.

I'm receiving data when querying through a browser (chrome), so there's no issue with the URL itself and the data is loading in the query editor.

Where am I going wrong?
  • Yes, that's why I proposed it as a workaround ;)

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi seann,

     

    Which authorization mode your api request? (oauth or other) Have you used advanced operations?(merge, append, combine, refresh query, custom functions) Did refresh operation works on query editor side?

     

    Please share more detail informations to help us clarify your scenario.

     

    BTW, you can also refer to below link to know how to trace detail error message:

    Handling 404–Not Found Errors With Web.Contents() In Power Query And Power BI

     

    Regards,
    Xiaoxin Sheng

    • seann's avatar
      seann
      Frequent Visitor

      Thanks for your reply Anonymous

       

      I've traced the error to one of URL encoding. When loading the data to the model, Power BI is decoding a "%2f" in the URL to a "/", which must be encoded. See below.

       

      https://[DOMAIN]/[PATH]%2fuser?[QUERY]

       

      I've tried forcing the "/" to be encoded in the M query, which works in the Query Editor using "Uri.EscapeDataString("/").

      let
          Encoded = Uri.EscapeDataString("/"),
          Source = Json.Document(Web.Contents("https://[DOMAIN]/[PATH]" & Encoded & "user?[QUERY]", [Headers=[Authorization="[AUTHKEY]"]]))
      in
          Source

      This is ignored when loading data to model and I'm received (redacted) the "/" decoded, which is causing the 404 Error.

       

      OLE DB or ODBC error: [DataSource.Error] Web.Contents failed to get contents from 'https://[DOMAIN]/[PATH]/user?[QUERY]' (404): Not Found.

       

      Unfortunately, the API I'm working with requires this section of the URL to be encoded (I've tested this outside of PBI). I'm able to view and model the data unimpeded in the query editor, but the encoding during the model loading is causing an Error 404. Is there a workaround for this?

       

      Thanks for your help!