Send POST requests
This section describes how to use a POST request to send data to an API to create a resource, and then assert that the call is successful.
Before sending a POST request, create a payload, that is data used to create a resource:
Enter the following values into the cell range A1:B2:
A B 1 first_name last_name 2 John Doe In cell C1, use the following formula to create a frame from the values in the range A1:B2:
=FRAME(A1:B2)In an empty cell, use the following formula to create a JSON string from the frame:
=JSON(C1)
Send the request and verify the response as follows:
In an empty cell, enter the POST() function with the URL "https://reqres.in/api/users" as the first argument and the address of the cell containing the JSON string as the second argument.
After a while, the POST() function returns a response in the form of a frame.
Open the frame by selecting the cell and pressing Shift + Enter.
Make sure that the nested spreadsheet that opens contains a nested spreadsheet with a date under createdAt, which for this particular REST API service means that the call is successful.