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.
Dear Community,
I am trying to connect Power BI with Web Api.
This one is working.
let
Source = Json.Document(Web.Contents("http://api-pub.dudooeat.com/auth/getAccessToken", [Headers=[#"X-Api-Key"="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx755"]]))
in
Source
I try to post the query, the API show error
let
refreshAccessToken=Json.Document(Web.Contents("http://api-pub.dudooeat.com/auth/getAccessToken", [Headers=[#"X-Api-Key"="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx755"]])),
body="scope=all",
Source = try Json.Document(Web.Contents("http://api-pub.dudooeat.com/sales/listCompanyId",[Headers=[#"Access-Token-Api"=refreshAccessToken,#"Content-type"="application/x-www-form-urlencoded",#"Content-Length"="6"],Content=Text.ToBinary(body)]))
in
Source
Is there any error in my query? 😞
Hi @Anonymous
In your 3rd step you have
data = Source1[data]
But Source1 (the JSON) doesn't contain a record named data - that's what's causing your error.
For debugging purposes remove all steps after Source1 = ..... and make sure to remove the comma at the end of the Source1 step too. You also need to tell the query what value is the result.
You should end up with something like this
let
body = .......
Source1 = ......
in
Source1
You can now check what Source1 is actually returning and go from there.
Regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
Hi @Anonymous
Your first step is returning a Record, not text. Click on the refreshAccessToken step andyou'll see what I mean.
So the body parameter is being set to a Record and this is throwing the error.
I can't tell you what's in the Record (its structure) as I don't actually have access to the API. But as you are trying to get the AccessToken I imagine the record will have a field in it named something like Token. You can check by clicking beside the Record as you did to see the error message.
So assuming the Access Token is in a field called Token you need to change the Headers in your second web request to
#"Access-Token-Api"=refreshAccessToken[Token]
Just match the field name from the record in the Header.
Let me know how you get on.
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
Hi, @PhilipTreacy
I try to avoid the error and use this methods
But found another problem
When I'm in Query Editor I can see the data tables with zero issues, but every single time when I try to do Close & Apply it failed
Best regards
Hi @Anonymous
Not enough info to know how to help. The error message willsay more than just Expression.Error - what's the full error message?
Regards
Phil
Proud to be a Super User!
Sorry I did not pay attention.
Put a photo to complete the problem.
Thank you for your help.
Hi @Anonymous
That code is syntactically ok.
What's the error you are getting?
Phil
Proud to be a Super User!
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 |
---|---|
96 | |
93 | |
83 | |
70 | |
65 |
User | Count |
---|---|
118 | |
106 | |
93 | |
79 | |
72 |