The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi, I am trying to connect to the an API with a blank query an am struggeling with the syntax
API instructions:
How do I write this query properly in PBI? I have tested mulitple things with different errors
one version I tried, which gives the follwing error which is not very helpful
let
Source = Json.Document(Web.Contents("http://blablabla.px",
[
Headers = [#"Content-Type"="application/json"],
Content=Json.FromValue([query = {}, response = [format = {"px"} ]])
]
))
in
Source
Have tried other methods for the content part (e.g. text.tobinary) but with no good result either. This M syntax is really confusing - please help! thanks and regards
Solved! Go to Solution.
thanks Daryl for your help. After some trial and error I found out that the instructions on the API was stated as ...format = ''px" , but this format (not sure what it is even) was not interpretable. Changeing this to format = ''json'' did the trick..
thanks Daryl for your help. After some trial and error I found out that the instructions on the API was stated as ...format = ''px" , but this format (not sure what it is even) was not interpretable. Changeing this to format = ''json'' did the trick..
Hi @steve1024 - it can sometimes help to split M steps up so that you have more visibility. Here is your original function:
let
header = [#"Content-Type"="application/json"],
body = Json.FromValue([query = {}, response = [format = {"px"} ]]),
Preview = Text.FromBinary( Body , BinaryEncoding.Base64 ),
Source = Web.Contents(
"http://blablabla.px",
[
Headers = header,
Content = body
]
),
Json = Json.Document( Source )
in
Json
This generate the following Preview of the JSON.
If this is formatted:
{
"query":[],
"response": {"format":["px"]}
}
It does not quite match the above. I have removed the {} around px. please test and trouble-shoot this way.
let
header = [#"Content-Type"="application/json"],
body = Json.FromValue([query = {}, response = [format = "px"]]),
Preview = Text.FromBinary( Body , BinaryEncoding.Base64 ),
Source = Web.Contents(
"http://blablabla.px",
[
Headers = header,
Content = body
]
),
Json = Json.Document( Source )
in
Json
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
34 | |
19 | |
18 | |
17 | |
13 |