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.
Hi All,
I got error while trying to get the data using web api with basic authentication.
From the message error as I attached, is that true ?
Or any solution for my issue ?
Please help
Thanks
Dear @PhilipTreacy
Yes, Web.BrowserContents only supports anonymous connections
> Well noted.
What exactly are you trying to do?
> I'm trying to get data using that API
If you need to provide authentication to an API you can use a different web connector and provide the auth that way
> I have been using all of these web conector in power bi like Web, OData, Web API but cannot reach the data
Thanks
have you tried adapting my code to get your API data?
Please post the query you are currently using (removing any username and password) so I can see how it needs to be modified to get it working.
Regards
Phil
Proud to be a Super User!
Yes, Web.BrowserContents only supports anonymous connections. What exactly are you trying to do?
If you need to provide authentication to an API you can use a different web connector and provide the auth that way. Something like this
let
// Get the API Token
api_url = "https://api.paypal.com/",
token_path = "v1/oauth2/token",
ClientID = "xxxxxxxx",
Secret = "xxxxxxxx",
EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(ClientID & ":" & Secret), BinaryEncoding.Base64),
Token_Response = Json.Document(Web.Contents(api_url,
[
RelativePath = token_path,
Headers = [#"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=EncodedCredentials],
Content=Text.ToBinary("grant_type=client_credentials")
]
)
),
in
Token_Response
Further reading which may help you
Getting Started with API's in Power Query • My Online Training Hub
Connecting to an OAuth API Like PayPal With Power Query • My Online Training Hub
regards
Phil
Proud to be a Super User!
Sorry for late replay.
I tried to using your code to get the data, but still no get that.
If you dont mind, could you help me to write correctly. Currently, this is the code like this
(SelectedService as text,Authentication as text) =>
let
#"BaseURL" = "My Url", //this url just masking for your demo
#"ConstantVar" = "my constant var", //this url just masking for your demo
response = Web.Contents(
#"BaseURL",
[
Headers = [Authorization= Authentication],
RelativePath = #"ConstantVar" & SelectedService
]
),
jsonResponse = Json.Document(response),
Navigation = jsonResponse[data],
#"Navigation 1" = Navigation{0},
#"Converted to table" = Record.ToTable(#"Navigation 1"),
#"Transposed table" = Table.Transpose(#"Converted to table"),
#"Promoted headers" = Table.PromoteHeaders(#"Transposed table", [PromoteAllScalars = true])
in
#"Promoted headers"
Thanks
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |