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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

API Key Authentication Problem

I'm using API key for fetching data, My Api key expires in every 10 days so I define key in parameter .

web: https://MyUrl.com?Token={Key}

Everything working fine on dextop, but when I go to schedule refresh on web secrvice it shows me invalid credentials.

 

So I click on edit credentials.

Where i can see Url: & Authentication Method: 
I'm not allowed to edit URL part so I copied url and paste in notepad. I found API is attached in URL but when I closely see the API is diffrent which I pass in parameter.

 

How can I remove API key in Url part ? Or is there any other way to use API.

Capture.JPG

Thanks in advacne ..

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous thanks for reply.

 

I'm new to power BI and very less knowledge about API.

So, my  advance editor code: 

 

let

Source = Json.Document(Web.Contents("https://re-client-proxy.TEST.XXYY.com/reporting/v3/state?token=KEY")),
 #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Err

 

in


 #"Converted to Table"

 

 

 

I tried to convert this into format as website described but ended up with:

" We couldn't authenticate with credentials provided." I select every option from drop down but it failed to pass.

 

let
apiUrl = "https://re-client-proxy.TEST.XXYY.com/reporting/v3/State?",
options = [Headers =[#"token"="KEY"]],
result = Web.Contents(apiUrl , options)
in
result

 

 

Anonymous
Not applicable

Hi @Anonymous,

 

See if this helps at all from my example below:

 

let
    Source = Json.Document(Web.Contents("https://www.myurl.com/",
[Query=[#"fields"="[briefDescription,parentIds]"],
Headers=[#"Authorization"="bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"],
RelativePath="/api/v3/tasks"
]
)),
data = Source[data],

 

Your query should look something like this:

 

let
Source = Json.Document(Web.Contents("https://re-client-proxy.TEST.XXYY.com",
RelativePath="/reporting/v3/state",
Headers=[#"TOKEN"="KEY"])),
 #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

 
in

 #"Converted to Table"

Anonymous
Not applicable

Hi @Anonymous 

Thanks for reply,

 

I used your query but getting error.

Capture.PNG

 

So when I click to Go to error, its showing "Expression.Error: The name 'RelativePath' wasn't recognized.  Make sure it's spelled correctly."

 

So I add "[]" in your query highlighted with red and again end up in credentials invalid"

 

let
Source = Json.Document(Web.Contents("https://re-client-proxy.xxx.com",
[RelativePath="/reporting/v3/state",
Headers=[#"TOKEN"="KEY"]]
)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)


in

#"Converted to Table"

 

Anonymous
Not applicable

I would reccommend using Fiddler to debug your web calls at this point.

 

You can acutally see the traffic that is getting sent to your web service. Compare the calls from Power BI and the known good source.

Anonymous
Not applicable

Hi @Anonymous

 Thanks for reply.

 

I don't have knowledge abt Fiddler, but I'm  doing R&D with fiddler. 

 

I asked my dev. to convert web address to Curl, so that I can find which header he is using for token. But I didn't find any header for token. Is it right way to attach token with add.

 

@Anonymous do you think this is y, I fnd token in URL while setting schedule refresh and Because of that when token expires in 10 days schedule refresh not working as old token still there in URL even after I've updated token in desktop. 

 

Anonymous
Not applicable

If your token is only good for 10 days you need to setup the data connection to refresh the token.

 

Here is a example how Micorsoft oauth2 works:

 

https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-...

 

This might be a good starting point.

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors