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
samuelfeldt
Frequent Visitor

PowerQuery Web Scenario: GET API, Header api key, Content Body

It appears that you are unable to use PowerQuery in a Scenario where you need:

  • GET HTTP Method
  • Header API Key
  • Content Body
let 
Url="url",
header = [#"x-api-key"="xxxx",#"Content-Type"= "application/json"],
Query="querystring",
body=[encoded_query=Query],

response = Web.Contents(Url, [Headers=header, Content=Json.FromValue(body)]),
Source = Json.Document(response)
in Source

^This design with Anonymous credential returns an "Expression.Error: Access to the resource is forbidden." indicating it does not read the header.

 

let 
Url="url",
header = [#"x-api-key"="xxxx",#"Content-Type"= "application/json"],
Query="querystring",

apiKeyName="x-api-key",
body=[encoded_query=Query],

response = Web.Contents(Url, [Headers=header, ApiKeyName=apiKeyName, Content=Json.FromValue(body)]),
Source = Json.Document(response)
in Source

^This design with Web API credential returns an "DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously. Details: DataSourceKind=Web, DataSourcePath=url" indicating I cannot supply a Web API Credential with a Content body.

 

let 
Url="url",
header = [#"x-api-key"="xxxx", #"Content-Type"= "application/json"],
Query="querystring",
body=[encoded_query=Query],

response = WebAction.Request(WebMethod.Get, Url, [Headers=header, Content=Json.FromValue(body)]),
Source = Json.Document(response)
in Source

^This design with any credential returns an "Expression.Error: We haven't been given permission to perform actions against this resource." indicating WebAction.Request does not force the method to GET.

 

This combination is the only valid scenario to request this API.

Any thoughts?

3 REPLIES 3
lbendlin
Super User
Super User

That is correct. As soon as you specify a content body Power Query will automatically change from GET to POST.

Went ahead and submitted an idea. Not sure what the purpose of forcing to POST is.

 

https://ideas.powerbi.com/ideas/idea/?ideaid=2d5b9bd6-cc43-ec11-a3ee-501ac524503c

There's a big can of worms over there... you could argue the same for PATCH etc.  Power Query only provides minimal HTTP request support.

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.