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
Anonymous
Not applicable

Unable to send a POST Request in Power Query

Hi,

 

I need to send a POST request to generate an access token in Power Query. In Power BI Desktop, a POST request is sent, and it works as expected. However, when I try to refresh after publishing the report to Power BI Service, a GET request is sent instead, resulting in a "Method Not Allowed" error, and a response code of 405.

This is the error I have encountered.

Kaveesha_Silva_0-1678436980064.png

This is the Power Query code I’m using

 

 

let
    base_url = [base_url],
    client_secret = [client_secret],
    Source  = Json.Document(Web.Contents(base_url&"/oauth/issueToken",
        [ 
          Headers = [#"Content-Type"="application/json"],
          Content=Json.FromValue([
            grant_type = "client_credentials",
            client_id = "powerbi_client",
            client_secret = client_secret
          ])
        ]
    )),

    token = Source[access_token],

 

 

I'm uncertain if the problem lies with the headers and content we are using. However, I was able to send the request successfully via Postman by setting the "Content-Type" to "application/json". What’s the issue here? Any issue with my script?

 

 

2 REPLIES 2
Poohkrd
Advocate I
Advocate I

Hi! Try this code:

let
    base_url = [base_url],
    client_secret = [client_secret],
    Source  = Json.Document(Web.Contents(base_url,
        [ 
          RelativePath = "oauth/issueToken",
          Headers = [#"Content-Type"="application/json"],
          Content=Json.FromValue([
            grant_type = "client_credentials",
            client_id = "powerbi_client",
            client_secret = client_secret
          ])
        ]
    )),

    token = Source[access_token],

 

Anonymous
Not applicable

Thanks for the reply, seems it doesn't resolve the existing issue

 

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.