Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Web API Key Authentication

Hello,

I am trying to connect to a Web API in Power BI Desktop. The request requires token authentication with an "api_key" parameter.  I continue to get the error that an API key name must be specified in order to provide an API key, but I cannot find where to specify an API key name.

 

I have already tried the following and none have worked:

  1. Anonymus authentication with providing the API key in the URL as a parameter
  2. Basic authentication with the API key as the username
  3. Web API authentication and provided the api key as the key value
  4. Adding a Header in the advanced UI called "Authorization" and providing the key. I also tried to specify the API key name here as "api_key".

I have seen other posts suggesting to create a dataflow to solve this but I do not have the ability to create a dataflow. 

 

What is the proper way to provide token authentication for a Web API?

 

 

Thanks,

8 REPLIES 8
Victor_Lecomte
New Member

Hello @Anonymous ,

I am encountering the same issue. Were you able to find a solution?

Thanks,
Victor

Anonymous
Not applicable

Hi @Anonymous ,

 

As the official document said, "api_key" is just an example, so it should be based on your actual URL in this format: "https://contoso.com/api/customers/get?api_key=****** 

Eyelyn9_1-1647594628924.png

 

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi! so "api_key" is actually the same as I need for my URL format.

 

Additionally, I attempted to do this just as a Blank Query in the advanced editor to bypass the Authentication in the Web API UI. I am still getting errors. Do you have any other tips on how to get this done?

 

There really should be a much easier way to provide auth for this...

Anonymous
Not applicable

Hi-  I have tried that, I have started a blank query and input Web.Contents("my api URL", [ApiKeyName="api_key"]) and saved it, and tried to Get Data from Web using the same api URL and selecting Web API inputting my key in the box. 

 

I still get the warning that I need to specify an API key name. Could it be that it is not specified in the right editor? Is there any where else to pass this auth?

Anonymous
Not applicable

I tried the auth trick by putting the api_key in the URL as a parameter and selecting Anonymous, that did not work. I received the error that I have invalid credentials but when I test my call in Postman with the same api key, it is fine.

 

This is the query I have currently: which is still giving me the error that I have invalid credentials.

adwilliams_0-1647286033342.png

 

Three years late, but for posterity and accuracy... the code above is actually two PQ applied steps returning the first step.  The second step is named ApiKeyName with literal text value "api_key".  This should have placed inside the 2nd parameter as a field of a record.  Hence...

Web.Contents("https://.......", [ApiKeyName="api_key"])





lbendlin
Super User
Super User

Have a read here Web.Contents - PowerQuery M | Microsoft Docs , specifically the ApiKeyName section.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors