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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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. 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors