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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Daz4
Helper I
Helper I

Dataflows - Web API - authentication

Hi Power BI Community!

 

I can access a particular web api via Power BI desktop, by using the URL, adding the below header and selecting Anonymous. 

 

Header = APIKEY

Value = xxxxxxxx

 

However, I cannot for the life of me work out how to connect to the same Web API using Dataflow. I cannot see anywhere to add the header, and if i tag it onto the end or the url (ie. &apikey=xxx) or whatever I try, I just get Incorrect Credentials error. 

 

I would massively appreciate any assstance on this as its doing my head in. 

 

I have been able to setup a Dataflow to another Web api, however that one uses a User name so I can configure it under Basic. The one i have issues with doesnt provide a username. 

 

Cheers!

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

If you have it working through Desktop, you can create a Dataflow from Blank Query and copy/paste your M code from the Advanced Editor in Desktop.  Have you tried that?

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
mwoollen
New Member

I believe that @Daz4 was asking how to add headers to an http GET via Web.Contents.

 

See code snippet below which shows how to encode user/password for Basic authentication.  Also demonstrates how to include multiple Headers in a Web.Contents call.

let
  Username = "[your username]",
  Password = "[your password or TOKEN]",
  UserPass = Username & ":" & Password,
  Bytes = Text.ToBinary(UserPass),
  Base64_UserPass = Binary.ToText(Bytes, BinaryEncoding.Base64),
  TargetURL = "[target URL]",
//TargetURL = "https://companyxyz.atlassian.net/rest/api/latest/search",
  Source = Json.Document(Web.Contents(TargetURL,
  [
     Headers = [
      #"Authorization" = "Basic " & Base64_UserPass, 
      #"Content-Type" = "application/json"
     ]
  ]
  ))
in
  Source

  

Once you have verified that your included Headers work... THEN you can follow @mahoneypat suggestions of copying M Query from Desktop Power BI.  Again, the problem stated was related to including Headers in a Web.Contents call, as PowerApps DataFlow to Dataverse connection properties do not allow Basic (or other) Authentication methods besides Anonymous and Organization. 

 

Note... this works great with JIRA extraction... see commented example inline.

v-stephen-msft
Community Support
Community Support

Hi @Daz4 ,


Sorry to disturb you...


But did I answer your question ? Please mark my reply as solution. Thank you very much.

 

Best Regards,
Stephen Tao

v-stephen-msft
Community Support
Community Support

Hi  @Daz4 ,

 

Please check this if it is help you:

https://docs.microsoft.com/en-us/power-query/handlingauthentication

 

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.

Hey Stephen, sorry for the delayed response, but this didnt help. I cant see anywhere in the options for setting up a dataflow to put the correct api authentication, and that document seems more focused on power query. Any other ideas? As I said, I can acess other aapis fine, and can access this one via Power BI desktop, just not through Dataflows. 

mahoneypat
Microsoft Employee
Microsoft Employee

If you have it working through Desktop, you can create a Dataflow from Blank Query and copy/paste your M code from the Advanced Editor in Desktop.  Have you tried that?

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks Pat, I never thought of that but it does the job, thats just brilliant thankyou!

 

I would still like to know why the Dataflow wont allow that but you have got my problem solved! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors