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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
MovhHMH
Frequent Visitor

Looping problem with POST request to API using API key & request body

Sorry if there's bad formatting, this is my first time posting here.

I've been trying to wrap my head around this problem, and tried looking for a solution, but ultimately came up empty handed. Here is the scenario, I have an API I am trying to access. This is done through an API key and its value. I can connect to it no problem. The problem arises when I need to include the body (internal error 500 otherwise). I then include the body as content, but I now run into the issue that this is only supported when connecting anonimously. When I try this, I am then met with the following "A web API key is required when a web API key name is provided." Hence, it seems to me that fixing one causes the other, which is why I'm currently in a loop to try and figure out what to do. From what I've read, I understand that a POST request is only possible through the anonymous authentication method. But how can I resolve this issue then? Code below (replaced some values with placeholders).

 

 

let
     body = "{""query_filter"":""}",
     Source = Web.Contents(
          "link?key=value",
          [
          ApiKeyName = "key",
          Headers = [ #"Content-Type" = "application/json" ],
          Content = Json.FromValue(body)
          ]
     ),

     result = Json.Document(Source)
in
     result

 


For the anonymous web content access I use the same link:
link?key=value

1 ACCEPTED SOLUTION
MovhHMH
Frequent Visitor

Thanks for the response Ibendlin. I have figured out the issue. It seems unfortunately, it is not possible to utilize authorization while also trying to use the "Content" parameter, as it changes Power BI's GET request into a POST request, which can only be done on anonymous authorization.

 

The issue was resolved, however it was done by removing the requirement of the "content" parameter on the APIs end. 

View solution in original post

2 REPLIES 2
MovhHMH
Frequent Visitor

Thanks for the response Ibendlin. I have figured out the issue. It seems unfortunately, it is not possible to utilize authorization while also trying to use the "Content" parameter, as it changes Power BI's GET request into a POST request, which can only be done on anonymous authorization.

 

The issue was resolved, however it was done by removing the requirement of the "content" parameter on the APIs end. 

lbendlin
Super User
Super User

Please consult the documentation, look at the examples.

 

Web.Contents - PowerQuery M | Microsoft Learn

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.