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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vamshikrishna20
Helper III
Helper III

Web API Authentication with API Key

Hi All, 

 

I have issue in getting data from web api . I got the url and Api key from client . In Postman iam passing the url with header as API key and key value. But In Power BI , under http request parameter i cant find api key . I cant simply pass the url as it says access is forbidden . so i manually given the API KEY and value , but it says apikey works only with anonymous access .

 

iam not sure how to move ahead. please help me to get out of this 

6 REPLIES 6
ReportGuru
Helper IV
Helper IV

Hi @vamshikrishna20 

I know this reply is very late lol. Since the Mailchimp service pack was deprecated, you would have to look for another way. As a workaround, maybe you can use a 3rd party connector, it can save you a lot of time compared to other options. I've tried windsor.ai, supermetrics (which doesn't have PBI as a destination, so you first have to export to Google Sheets and then export to PBI) and funnel.io. I stayed with windsor because it is much cheaper so just to let you know other options. In case you wonder, to make the connection first search for the Mailchimp connector in the data sources list:

 

ReportGuru_0-1711579151666.png

 

 

After that, you will have to first create a secret API key in your Mailchimp account and then using your credentials add your account to the platform.

 

ReportGuru_1-1711579170832.png

 

 

Once you’ve done this, you can proceed and go to the “Preview and destination” step

 

ReportGuru_2-1711579170836.png

 

 

There just select the fields you need. Finally, just select PBI as your data destination and finally just copy and paste the url on PBI --> Get Data --> Web --> Paste the url. 

v-luwang-msft
Community Support
Community Support

Hi @vamshikrishna20 ,

By using an Azure Function Proxy it is possible to bypass the Power BI restriction of not being able to do anonymous authentication on Web data sources that require an API key.

to learn more detail ,refer:
https://blog.kloud.com.au/2018/07/23/use-anonymous-authentication-on-web-data-sources-with-a-api-key... 
 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

PhilipTreacy
Super User
Super User

Hi @vamshikrishna20 

You haven't said what API you are trying to access or if you have checked the API documentation which should tell you how to connect to it and get data.

Another way to make the query is this

let
    api_url = "https://api.com",
    ClientID = "",
    apikey = "YOUR-API-KEY",
    
    EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(ClientID & ":" & apikey), BinaryEncoding.Base64),

    data= Json.Document(Web.Contents(api_url,
   [ 
     Headers = [#"Authorization"=EncodedCredentials]
   ]
   )
   )

in
    data

This format works with an API like Mailchimp that only provides an API key.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @vamshikrishna20 

How does the API specify that you use the API Key to connect to it?  I don't know, the API documentation should tell you.

How did you get the API Key?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @vamshikrishna20 

What API are you trying to access?

You probably need to pass the username/password/api key as part of the request headers.  I don't know exactly how your API requires this or what you mean by an API Key but I've seen API's where the API Key is passed as the Username and the Password is left blank.

Try this code and leave the Password as ""

Enter your API Key as the Username and enter the correct URL to the API 

 

 

    Username = "xxxxxxxx",
    Password = "",
    api_url = "https://api.com/",
    
    EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(Username & ":" & Password ), BinaryEncoding.Base64),
    
    Token_Response  = Json.Document(Web.Contents(api_url,
    [ 
      Headers = [#"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=EncodedCredentials],
      Content=Text.ToBinary("grant_type=client_credentials")
    ]
    )
    )

 

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi @PhilipTreacy ,

 

I dont have basic auth credentials. I only have API key and url

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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