💫

Connect to any API: POST request

The Data Library allows you to create API requests to any database or tool with an available REST API.

Here is how to create a POST request to create data in the external database from your app.

💡

You can utilize other API verbs (i.e. PUT) to create data if your API specifies otherwise. Simply change the verb type of the request URL.

Example Database

Copy this Airtable as the database to send data. We will follow Airtable's API documentation to set up the POST request below.

Airtable API documentation for POST requests
Airtable API documentation for POST requests

How to set up a POST request

  1. In Data Library, click + New Collection and select Custom API.
  2. image

  3. Enter the name of your collection and an optional description (we recommend putting the data source as the description, like Google Sheet).
  4. 💡

    A Collection is a group of API requests, usually for the same data source.

    image

  5. Edit the request name to help you identify it + change the request type to POST.
  6. image

  7. Input the POST request URL from the API of your choosing.
  8. image

  9. The API documentation specifies any Headers, Parameters, and/or Body value needed in order to make the POST request. In this example, we'll show what Airtable requires.
  10. For Header: H "Authorization: Bearer YOUR_API_KEY"

    Airtable POST request: Header input
    Airtable POST request: Header input

  11. The type of the body of the request is indicated by the Content-Type header.
  12. For Body: Airtable indicates H "Content-Type: application/json". Therefore, under Body, select JSON.

    6A. Copy one record data from the Example Request in the API documentation. Make sure you have the same amount of opening and closing brackets.

    image

    6B. Change the example value to input variable ${input}. (in this screenshot, Chris and 20 are the example value).

    💡

    The input variable name between ${} can be anything, it's for you to later identify in Data Binding and it will be replaced by the user input in the app. Permitted characters: lowercase a-z, uppercase A-Z, 0 to 9, underscore (_) and dash (-). No spacing.

    ⚠️

    For text input, include the quotation marks, like "${input}" For number input, do not include the quotations, like ${input}

    {
      "records": [
        {
          "fields": {
            "Name": "${name}",
            "Score": ${score}
          }
        }
      ]
    }
    Airtable POST request: Body input
    Airtable POST request: Body input
    ⚠️

    If you get 400 Bad request Error please review and double check your Body JSON to be correct.

  13. For Parameters: depending on how many fields you have in the Body, you will need corresponding parameters. In the example, there are 2 fields: ${name} and ${score}. Put the input name in the Key field, and a test content (can be anything you want) in the Value field.
  14. The example content will appear in your database in the next step if the POST request is set up correctly.

    image

  15. Press Send. You have successfully set up the POST request if:
    1. You receive a response list under Received Data.
    2. image
    3. The test content from Parameters is sent to your database.
    4. image
      💡

      If you encounter any error message after clicking Send, screenshot it and send it to us from the Help button at the bottom right corner (for Olé and Bravissimo users) or post in the Bravo community.

  16. From the Received Data list, select the data paths that you want to use as "Content Destination" in your app (where the user input will be sent).
  17. image