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
ivan_larson_cki
Helper III
Helper III

REST API Token Authentication in Service

I'm trying to build a connection to a program that uses REST API. I have an API token for our datasets, and the API URL of a table I need. In PBI Desktop, I used the interface for a "Web" connection, and I set the "HTTP request header parameters" to "api-token" and entered the token. So the token is listed in my query:

 

 

 

let
    Source = Json.Document(Web.Contents("https://ourproject.theurloftheprogram.com/api/project/active", [Headers=[#"api-token"="thisisalongstringoflettersandnumbersthatisntactuallyanapitokendontputanapitokenwhereanyonecanseeit"]])),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"EstimateAtCompletionToTargetTotalPercent_Variance", "EstimateAtCompletionToTargetTotal_Variance", "etc", "et cetera", "and so forth"}, {"Column1.EstimateAtCompletionToTargetTotalPercent_Variance", "Column1.EstimateAtCompletionToTargetTotal_Variance", "Column1.etc", "Column1.et cetera", "Column1.and so forth"})
in
    #"Expanded Column1"

 

 

 

 

But when I upload the query into PBI Service and  try to set up a refresh, I get an error because my credentials are invalid. The only options I have are either to access the site anonymously or with my login credentials. Neither works. Do I need to reconfigure where I enter the API token?

 

Here's the error message:

"

Failed to update data source credentials: The credentials provided for the Web source are invalid. (Source at https://ourproject.theurloftheprogram.net/api/project/active.)Hide details

Activity ID:8567ae3a-3b9a-4972-b570-b4c8f4299768
Request ID:6b3890e8-b5dd-8f70-94a4-501e07f4f716
Status code:400
Time:Mon Feb 15 2021 08:45:33 GMT-0600 (Central Standard Time)
Service version:13.0.15383.18
Client version:2102.2.04869-train
Cluster URI:https://wabi-west-us-redirect.analysis.windows.net/

"

1 ACCEPTED SOLUTION
ivan_larson_cki
Helper III
Helper III

Problem is solved. It turns out I just needed to skip testing the credentials on the settings page for the dataset. When I actually refreshed the data, it worked fine.

View solution in original post

3 REPLIES 3
ivan_larson_cki
Helper III
Helper III

Problem is solved. It turns out I just needed to skip testing the credentials on the settings page for the dataset. When I actually refreshed the data, it worked fine.

v-stephen-msft
Community Support
Community Support

Hi @ivan_larson_cki ,

 

There's an official document about refresh failure when updating data from sources using AAD OAuth:

https://docs.microsoft.com/en-us/power-bi/connect-data/refresh-troubleshooting-refresh-scenarios#ref...

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Stephen,

 

Thank you for your response. The linked issue is not the one occurring here as I'm not able to schedule refreshes to begin with. On the dataset's settings page, I'm told "Your data source can't be refreshed because the credentials are invalid. Please update your credentials and try again." When I try to enter credentials, I get the error message I just added in the original post.

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
Top Kudoed Authors