Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Unable to send POST request in Web.Contents


I need to retrieve employee data from an API that's only accessible to authorized users. First, I send a POST request using client credentials to obtain a bearer token and then it can access the employee API with this token. This process works smoothly on Power BI Desktop. However, once I publish the report to Power BI Service, the access token request becomes a GET request, resulting in a "Method Not Allowed" error with response code 405. 


This is the error I have encountered.




Failed to update data source credentials: Web.Contents failed to get contents from '' (405): Method Not AllowedHide details
Activity ID:	56d0cb6a-3c96-4b10-8ae5-1de4fc1cd8e8
Request ID:	43940e4e-6384-e9ab-7d05-54e2ad842885
Status code:	400
Time:	Thu Mar 09 2023 15:35:33 GMT+0530 (India Standard Time)
Service version:	13.0.20195.63
Client version:	2302.4.12605-train
Cluster URI:




This is the Power Query code



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

    token = Source[access_token],

    data= Json.Document(Web.Contents(baseUrl&"/api/employees",
        Headers = [#"Authorization"="Bearer "&token]
    data1 = data[data],
    #"Converted to Table" = Table.FromList(data1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"empNumber", "firstName", "lastName", "middleName", "termination_id", "employeeId", "joinedDate", "deletedEmployee"}, {"empNumber", "firstName", "lastName", "middleName", "termination_id", "employeeId", "joinedDate", "deletedEmployee"})
    #"Expanded Column1"




According to the documentation, "Content" specifies that the web request should be changed from a GET to a POST, with the value of the option being used as the content of the POST request. As I have mentioned earlier, this is working fine in Power BI Desktop, but not in the Power BI Service as expected.


What’s the issue here? Any issue with my script?







Regular Visitor

Thanks for the quick reply Chirs. Here we are not really trying to get the full OAuth2 flow implemented. The main issue here is why the POST request works properly in PowerBI Desktop but converts into a GET in Power BI Connect(Cloud). We removed all the dynamic parts and tried to hard code the values to see whether the issues are due to dynamic params. Still no luck.


For more complex authentication flows (such as OAuth2) you need to build a custom connector, because the necessary functionality is only available there. See for more details.



Helpful resources

Exciting changes

Power BI Community Changes

Check out the changes to the Power BI Community announced at Build.

May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Kudo Data Story carousel

Data Stories Gallery

Visit our Data Stories Gallery and give kudos to your favorite Data Stories.