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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
TheChilOne
Regular Visitor

First time API connection - Base64 Encoded

I am trying to connect to a URL; however, I get a credential error.  I have passed the Base64 encoded APIKEY and Session TOKEN through the header using the Power Query Advanced Editor, and there are no syntax errors.  It then says edit credentials.  When I go to choose anonymous it says invalid credentials.  If I try the Web API credentials it gives me the error stating I need a API Key named in the header.

 

Any help would be appreciated.

 

let
Source = Web.Contents("https://URLHERE", [Headers=[Authorization="Basic Bases64Encode Here="]])
in
Source

 

community question.png

 

2 REPLIES 2
TheChilOne
Regular Visitor

V,

I am sorry but I have read the post and still can not figure this out.  I am a CPA that took a few C++ courses in college 20 years ago, and spent alot of time developing UI solutions using MS Access and SharePoint as a datawarehouse during that time.  I like to think I was doing powerplatform stuff before the powerplatform was branded.

 

Can you look at the advanced editor screen and point me in the right direction of where I need to code?


I did confirm this is a GET, not POST

 

I have verified the API_KEY and TOKEN are correct.  When encode to Base64 I use the values in the converter like this API_KEYTOKEN.  Here is how the content provider describes the headers:

Authentication in header can use Authorization field in following format:
Authorization: Basic {basicHash}
basicHash is base64 encoding of resulting string from: {API_KEY}:{TOKEN}
Example authorization header: $header = ['Authorization : Basic ' . base64_encode(API_KEY . ':' . TOKEN) ];

 

Should I be encoding the API_KEY and TOKEN differently?

 

I get invaild credentials when I use API_KEYTOKEN in the base64 converter.  But if I add the :, like API_KEY:TOKEN in the converter I get a Bad Request error, so it never passes to the credentials.

 

I would also take a reccomendation on a developer that can assist.  I am a one man shop at the moment but can pay for some help to get this connected.

 

community question 2.png

V-lianl-msft
Community Support
Community Support

Hi @TheChilOne ,

 

If the API method is get, please refer to this blog.

https://blog.crossjoin.co.uk/2014/03/26/working-with-web-services-in-power-query/ 

If the API method is post, you also need to refer to these:

https://blog.crossjoin.co.uk/2014/04/19/web-services-and-post-requests-in-power-query/ 

https://social.msdn.microsoft.com/Forums/en-US/029fed1d-56fe-476a-9d7d-f367c5036b6e/posting-xml-to-a... 

 

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.