Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello,
I'm trying to use the Advanced Editor to make an API call for the first time. I've watched Chris Webb's excellent video on the subject and took a bunch of notes, but i'm missing something here. In the video, I noted his call as:
let
Source = Web.Contents("https://baseURL",
[
RelativePath="hello",
Query = [
key = "value1"
key = "value2"
],
ApiKeyName = "apikeyskdjf;asdkfj]"])
]
)
in
SourceBut my query parameters didn't like this format.
The call I'm trying to make is a GET request:
let
Source = Web.Contents(
"https://somecompanysAPI.com/v2/",
[
RelativePath="historical",
Query =
{
"geocode": {
"lon": -122.31177520752,
"lat": 47.4498901367188
},
"location_id": "",
"start_time": "2017-11-01T12:00:00Z",
"end_time": "2017-11-07T12:00:00Z",
"timestep": 60,
"fields": [
{"name": "temp", "units": "F"},
{"name": "feels_like", "units": "F"},
{"name": "dewpoint", "units": "F"},
{"name": "wind_speed", "units": "mph"},
{"name": "wind_gust", "units": "mph"},
{"name": "baro_pressure", "units": "inHg"},
{"name": "visibility", "units": "km"},
{"name": "precipitation", "units": "in/hr"},
{"name": "cloud_cover", "units": "%"},
{"name": "cloud_ceiling", "units": "ft"},
{"name": "cloud_base","units": "ft"},
{"name": "humidity", "units": "%"},
{"name": "wind_direction", "units": "degrees"},
{"name": "precipitation_type"},
{"name": "sunrise"},
{"name": "sunset"}
]
}
ApiKeyName = "thisisnotreallymyAPIkeydude"
]
)
in
SourceCan someone with more experience see what I'm missing here as far as syntax goes?
Thank yoU!
Solved! Go to Solution.
Ok! I figured this out from the great example in the Forums found here: https://community.powerbi.com/t5/Desktop/Connect-to-a-Web-Service-sending-parameters/m-p/295990#M130.... Thank you @Anonymous!
Here is what I ended up going with:
let
url = "https://company.com/api/path",
headers = [
#"apikey" = "thisisnotreallymyapikey",
#"accept" = "application/json",
#"Content-Type" = "application/json"
],
content = "{
""key"": {
""nestedKey"": value,
""nestedKey"": value
},
""key"": """",
""key"": ""value"",
""key"": ""value"",
""key"": value,
""key"": [
]
}",
webdata = Web.Contents(url, [Headers=headers,Content = Text.ToBinary(content)]),
response = Json.Document(webdata)
in
responseWhew! I should have searched the forums better! NOTED 🙂
Still needing some assistance here. I've boiled down the code a bit to make it easier to read. Can you see why this is not working?
I should be more clear here on what I'm looking for help with:
Method: POST
Authentication: API Key sent in Request Header
Parameterized Request?: No, JSON request, not a parameterized URL
Body: JSON
Request Headers?: Yes, 3 (apikey, accept, Content-Type)
Response: JSON
Response Headers?: Yes, 11 (though I don't think I need to craft the response headers, they should auto)
Error in Advanced Editor: "Invalid Identifier" error on the word "geocode".
I've tried "Query" and "Content" in the below M with no success. The docs on Web.Contents have NO examples (and the Github contribute link is broken on that site!). For some reason, not many people are making POST requests with PowerBI so there are like NO examples of this on the internet besides Chris Webb's video. But I can't glean how to do it from his video (@ ~24:54 mark) because he digresses a bit at EXACTLY the moment he covers POST requests!
let
Source = Web.Contents(
"https://somecompanysAPI.com/v2/historical",
[
Query = [
"geocode": {
"lon": -122.31177520752,
"lat": 47.4498901367188
},
"location_id": "",
"start_time": "2017-11-01T12:00:00Z",
"end_time": "2017-11-07T12:00:00Z",
"timestep": 60,
"fields": [
],
ApiKeyName = "thisisnotreallymyAPIkeydude"
]
)
in
SourceDoes anyone have insights on this? An example or two of how you do it?
Thank you very much!
Ok! I figured this out from the great example in the Forums found here: https://community.powerbi.com/t5/Desktop/Connect-to-a-Web-Service-sending-parameters/m-p/295990#M130.... Thank you @Anonymous!
Here is what I ended up going with:
let
url = "https://company.com/api/path",
headers = [
#"apikey" = "thisisnotreallymyapikey",
#"accept" = "application/json",
#"Content-Type" = "application/json"
],
content = "{
""key"": {
""nestedKey"": value,
""nestedKey"": value
},
""key"": """",
""key"": ""value"",
""key"": ""value"",
""key"": value,
""key"": [
]
}",
webdata = Web.Contents(url, [Headers=headers,Content = Text.ToBinary(content)]),
response = Json.Document(webdata)
in
responseWhew! I should have searched the forums better! NOTED 🙂
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 48 | |
| 40 | |
| 38 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 68 | |
| 66 | |
| 29 | |
| 26 | |
| 25 |