Forum Discussion

rkoehl's avatar
rkoehl
New Member
2 years ago
Solved

URL is accessible via web browser; however, Expression.Error: Access to the resource is forbidden

I have been having an issue for the past week with loading data from a public website that has previous been working for me.  Up until recently, I have been able to load this data with out any issues...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi rkoehl ,

    Given that you can access the URL directly through a web browser but not through Power Query, it's possible that the website now requires additional authentication or headers that your Power Query request does not currently include. Here are a few steps you can take to troubleshoot and potentially resolve this issue:

    1. Since you mentioned that this issue started occurring recently, it's possible that the website has implemented changes requiring additional authentication or headers. If possible, check the website's documentation or contact their support to see if there have been any recent changes to their access requirements.
    2. Power Query's Web.Contents function allows for specifying additional options such as headers. If the web source now requires a specific header for access, you may need to include this in your query. For example:

    let
        WebContents = Web.Contents("https://www.spglobal.com", [
            RelativePath = "spdji/en/idsexport/file.xls",
            Query = [
                hostIdentifier = "48190c8c-42c4-46af-8d1a-0cd5db894797",
                redesignExport = "true",
                languageId = "1",
                selectedModule = "PerformanceGraphView",
                selectedSubModule = "Graph",
                yearFlag = "tenYearFlag",
                indexId = "30000005"
            ],
            Headers = [Authorization="Bearer <Your_Token_Here>"]
        ]),
        XlsWorkbook = Excel.Workbook(WebContents, null, true)
    in
        XlsWorkbook

    3. Ensure that your Power BI environment and the account you're using have the necessary permissions to access the web source. This might involve checking if any organizational policies or conditional access settings have changed that could impact your access.

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