Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi everyone i hope all is well. I need some help/guidance regarding a error i get when trying to refresh data that is being fetched through a generated EHS insight Apikey name and key.
Below is the error i get even when using the anonymous authentication:
Expression.Error: The 'X-ApiKey' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Range, Referer
Hope to hear from you🥲😅
Solved! Go to Solution.
Hi @v-nuoc-msft ,
Thank you for the detailed explanation on this. I will try it next time. For now we just removed the api header and key from all sources and then changed the authentication to basic where we just gave a username and the api key as password and all seemed to be working well now.
Hi @v-nuoc-msft ,
Thank you for the detailed explanation on this. I will try it next time. For now we just removed the api header and key from all sources and then changed the authentication to basic where we just gave a username and the api key as password and all seemed to be working well now.
Hi @Nari1998
I understand that you are getting an error when trying to refresh data from a web API using an EHS insight Apikey name and key.
Based on the error message, it seems that Power BI is not recognizing the ‘X-ApiKey’ header as a valid authentication method for the web API.
Power BI only supports a few standard headers for web API authentication, such as Authorization, Cookie, or X-HTTP-Method. For other headers, such as X-ApiKey, Power BI will throw an error unless you connect anonymously.
However, connecting anonymously is not a secure or recommended way to access web APIs that require authentication. A better solution would be to use the Web.Contents function in Power Query to specify the custom header for the web API.
This function allows you to pass additional options for the web API request, such as headers, query parameters, or content type.
To use the Web.Contents function, you need to edit the query that connects to the web API in Power Query Editor. You can do this by following these steps:
In Power BI Desktop, go to the Home tab and click on Transform Data.
In Power Query Editor, select the query that connects to the web API and go to the Advanced Editor.
In the Advanced Editor, replace the existing code with the following code:
let
Source = Web.Contents("1", [Headers=[#"X-ApiKey"="your_api_key"]])
in
Source
In Power Query Editor, go to the Home tab and click on Close & Apply.
This should allow you to refresh the data from the web API without getting the error.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
93 | |
85 | |
84 | |
73 | |
49 |
User | Count |
---|---|
142 | |
133 | |
110 | |
68 | |
55 |