15

I was trying to get data from a vendor's REST API from Power BI.

When getting data, under Web API, it keeps throwing this error. See attached screenshot.

Error message screenshot

It is a POST method where you can filter by any field in the response body (yet I'm not passing any this time).

The query I am using to get a response is as below. Sorry I forgot where I found it.

let

    apiUrl = "my_api_url",

    token="my_api_key",

    options = [Headers=[Authorization="Bearer " & token ]],

    result = Json.Document(Web.Contents(apiUrl , options))

in

    #"result"

4 Answers 4

5

You need to include ApiKeyName in your request rather than building up Authorization yourself.

For example:

let Source = Web.Contents(apiURL, [ApiKeyName="mauapikey"]),

Also see Microsoft Documentation or someone's blog post

Sign up to request clarification or add additional context in comments.

Comments

1

I recently ran into a similar problem, but was able to find the solution:

If your authorization must be in the header, you were nearly there with your solution. In my case, the authorization was required to be in the header, but utilized Basic Authentication rather than Token. I believe if you do the following to your code, it will work

let

    apiUrl = "my_api_url",

    token="my_api_key",

    options = [Headers=[#"Authorization"="Bearer " & token ]],

    result = Json.Document(Web.Contents(apiUrl , options))

in

    #"result"

The only thing added is the '#' before the Authorization and then surrounding Authorization with double quotes "Authorization".

Comments

0

Do not try to add API on the WEB API section.

Select the BASIC authentication method and there you have to give the username and password.

here, the username is the account username where you created the API key. And Password is your API key.

For me, this worked.

Comments

0

I had exactly the same error trying to use an API key with a Power BI report referencing an Azure Application Insights REST API.

I got it working by not configuring any credentials in the underlying code, but by selecting "Basic" authentication and then adding the API key from the Application Insights resource in the username field and leaving the password blank.

(Then in Power BI admin dashboard the same worked though it wasn't happy with a blank password - I just added the API key for both username AND password instead.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.