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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shane-ds
Frequent Visitor

WebContent "Contents": How do you get this to work?

Hi,

 

Such generic terms describing this issue, I don't even know how to search for a resolution... I created and Azure Web Function and I can call the Azure Web Function from Postman - it's working without issue.

 

From Postman,

 

GET https://tiwlfunctions.azurewebsites.net/api/tiwlConnector
Request Header

sx-functions-key: ntw...
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: deadbeef-dead-dead-beef-deadbeefcafe
Host: tiwlfunctions.azurewebsites.net
Content-Length49

Request Body

{"clientName": "TI","resource": "Staff"}


In my Power BI Dataflow, I'm trying to call this API just the same using WebContent. But it doesn't work. The Azure API never gets hit. When I first created the Power Query WebContents, I accidently left out the Content, and it does hit the Azure API. Although, the Web Function will just return a BadRequest because it requires a Body (Content). However, every attempt I've made to include the Content yields the same result - it doesn't hit the API. There's no way to know why. There's no feedback in Power BI to diagnose what the problem is. I've tried many different header types, formatting, with/without Host and Content-Length, Cache-Control and and even Postman-Token. Any suggestions would be appreciated.

 

let
// Define the request body
requestBody = Json.FromValue([
clientName = ParameterClientName,
resource = "Staff"
]),
requestBodyText = Text.FromBinary(requestBody),
baseUrl = ParameterConnectorAzureUrl,
azureXCode = ParameterConnectorAzureXCode,
host = "tiwlfunctions.azurewebsites.net",
contentLen = Text.Length(requestBodyText),
// Define the request headers
headers = [
#"Content-Type"="application/json",
#"x-functions-key"=azureXCode,
Host=host,
#"Content-Length"=contentLen
],
binContent = Text.ToBinary(requestBody),
xbinContent = Text.FromBinary(binContent),
dataRequest = Web.Contents(baseUrl, [
Headers=headers,
Content=Text.ToBinary(requestBodyText),
RelativePath = "api/tiwlConnector",
Query = null
])
in
dataRequest
1 ACCEPTED SOLUTION
shane-ds
Frequent Visitor

I was probably was stuck on this for about 7 hours. Turns out adding "Content" the Power Query WebContents will do a POST, not a GET, whereas my Azure Function was only a GET.

View solution in original post

2 REPLIES 2
shane-ds
Frequent Visitor

I was probably was stuck on this for about 7 hours. Turns out adding "Content" the Power Query WebContents will do a POST, not a GET, whereas my Azure Function was only a GET.

Anonymous
Not applicable

Yes, you are correct.

 

For any Power Query function, you can always first go to the official document to find what a parameter represents. 

Power Query M function reference - PowerQuery M | Microsoft Learn

Web.Contents - PowerQuery M | Microsoft Learn

 

Best Regards,
Jing

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.