Data Import & Export

Send a POST Request to an API from Microsoft Excel

Khadija KhanKhadija Khan Nov 18, 2026 869 views

Question details

Send a POST request with a body and authentication details to an API from Excel.

Send a POST Request to an API from Microsoft Excel
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
The user wants to retrieve API data in Excel from an endpoint that requires a POST request.
Observed behavior
The standard From Web or From OData Feed interface may use GET and receive an HTTP 405 Method Not Allowed response.
Before you start

Check the API documentation for the exact POST endpoint, required headers, authentication method, and JSON or form payload. Confirm that your Excel version includes Power Query and that the API can return a response Excel can process.

Solution 1Recommended

Send a POST request with Power Query Web.Contents

Use a blank Power Query to send a JSON request body and headers when the standard connector does not offer the required POST configuration.

Adding the Content option to Web.Contents makes the request a POST. The example expects a JSON response and uses a bearer token; adjust the body and headers to match the API.

Power Query POST requests made with Web.Contents must use the Anonymous data source credential setting. A bearer token can be supplied in an HTTP header when the API supports it, but this approach may not work with every authentication scheme.

1
Create a blank query

In Excel, select Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor, select Home > Advanced Editor.

2
Enter the POST request

Replace the existing query with the following code, then select Done. Replace the example URL, token, and payload with the values required by your API: let Response = Web.Contents( "https://api.example.com/search", [ Headers = [ #"Content-Type" = "application/json", Authorization = "Bearer YOUR_TOKEN" ], Content = Json.FromValue([query = "example"]) ] ), Result = Json.Document(Response) in Result

3
Set the data source credential

If Excel prompts for credentials, choose Anonymous and connect. If credentials were saved previously, use Data > Get Data > Data Source Settings to edit or clear the permissions for the API URL.

4
Shape and load the response

In Power Query Editor, use To Table and the expand buttons as appropriate for the returned list or record. Select Home > Close & Load to load the resulting table into Excel.

5
Check an HTTP 405 response

If the request still returns 405, compare the URL and method with the API documentation, including any required path or trailing slash. Also verify the headers, authentication, and request body.

Send a POST request with Power Query Web.Contents
Protect API credentials: A token placed directly in query code may be visible to anyone who can access the workbook or query. Avoid sharing workbooks containing secrets and use an authentication approach appropriate to your organization.
Free Microsoft Office alternative

Work with Excel-compatible spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open Excel files in WPS Spreadsheets for an easy transition, while using Excel or another supported tool for the Power Query POST workflow.

Open and edit Microsoft Excel XLSX and XLS filesWork with spreadsheet data imported from API responsesUse a familiar interface that makes switching easierAccess a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel return HTTP 405 for my API request?

HTTP 405 means the endpoint does not allow the requested HTTP method. Check the API documentation for the exact URL and method; the standard From Web or From OData Feed interface may send GET when the endpoint requires POST.

How does Power Query send a POST instead of a GET?

In Power Query's Advanced Editor, add a Content value to Web.Contents. For a JSON body, Json.FromValue can convert an M record into the binary content required by the request.

Where do I add an API bearer token?

Add an Authorization header such as Authorization = "Bearer YOUR_TOKEN" in the Headers record of Web.Contents. Choose Anonymous for the Power Query data source credential, and avoid sharing a workbook that contains a token.

What if the API does not return JSON?

Do not use Json.Document unless the response is JSON. Change the query to process the actual response format, such as converting a text response with Text.FromBinary, according to the API documentation.