Related Articles: GET Requests | PUT, PATCH, & DELETE Requests
In this tutorial, we’ll discuss how to make a POST request from your Google Sheet to an API using the Apipheny add-on.
There are several methods for you to interact with APIs, such as receiving, sending, updating, or deleting data.
In Apipheny, the method you’ll probabyl most often use is GET, which lets you receive data from an API, but you can also send data to an API using the HTTP method called POST, which we will talk more about in this tutorial.
Below, we’ll show you just how quick and easy it is to use Apipheny for making a POST request in Google Sheets.
If you haven’t installed Apipheny yet, click here to install the add-on and follow along in your own Google Sheet.
Here’s a quick video tutorial to get you started:
To make a POST request from your Google Sheet, first open the Apipheny add-on in your Google Sheet and make sure your method is set to GET in the Method dropdown at the top of the Apipheny add-on:
After choosing the POST method, input your desired API URL into the API URL Path field:
A POST request requires you to input the data you wish to send to the server. You may input your data in the POST Body field:
Once you’ve finalized the details of your request, click Run to process your POST request:
Apipheny will then run your request. If your chosen endpoint is the type that sends back data, you should see that data show up in your spreadsheet, like so:
If you choose the POST, PUT, or PATCH request method, you will see two new fields appear called Body and Content Type:
The default Content Type is application/json, but there are several options to choose from. Just click the dropdown to see all the options:
If you have a body you need to send in your API request, make sure to enter it in the Body field.
Here is an example of a POST body with application/json content type:
{ "parameter1": value1, "parameter2": value2, "parameter3": value3, "parameter4": value4 }
Here is an example of a POST body with the application/x-www-form-urlencoded content type (no brackets):
"parameter"="value","paramater2"="value2", "parameter3"="value3"
POST requests require you to input data into the POST body. You may type your data manually, but it’s also possible to program Apipheny to automatically use data available in your spreadsheet.
To program your POST requests to use dynamic data, you must insert variables into your POST body by referencing cells from your spreadsheet. Learn more about referencing cell values.
Here’s an example of a POST body containing variables:
{ "Id": {{{Sheet1!A2}}}, "Customer": {{{Sheet1!B2}}}, "Quantity": {{{Sheet1!C2}}}, "Price": {{{Sheet1!D2}}} }
In the example POST body above, the “Id” parameter is pulling the value from cell A2 in Sheet1, the “Customer” parameter is pulling the value from cell B2 in Sheet1, and so on.
By referencing cells in your POST body, you won’t have to keep editing your POST request each time you want to send new data to an API.
That’s it! Making a Google Sheets POST request really is that easy using the Apipheny add-on.
Crypto API Tutorials: