How to use GET PUT POST..etc with a non google sheets API

Hey @stephenf1113!

Retool generated APIs are great for doing some testing or building out a sample but you'll likely want to use your own API for longer-term projects - in which case there's a good chance you'll need a syntax custom fit to that API!

That being said, here's an example of how you can get started with one generated by Retool (for some more documentation you can look here).

For starters, you can set up a GET request using just the URL provided by the API generator:

If you want to add a new row to your API you can do so with a POST request:

The key things to highlight here are that the Content-Type header is set to application/json. The Body type is then set to Raw so that the new row data can be passed directly from the .newRow property of your table using {{}}.

To edit rows you can use a PUT request. It has a similar Header and Body structure, but is a little different since it asks for an id to identify which row to update which is passed directly to the URL:

Since the PUT request only updates one row at a time, this pattern can be used to update a batch of rows together. Note that both the id and data are marked as undefined, that's because they'll only be defined at the moment the query is triggered using additionalScope! Below is an example of the code from the linked doc in the app itself:

As you may already be doing with Google Sheets, it's good to have your GET query as a success handler on both the bulkPut and post queries so that the frontend stays up to date:

And with that, you should have a working and modifiable API!

Hopefully, that helps! I've attached an app with all of it put together that you can play around with. (Note that you'll want to switch out the API URL with your own).

Let me know if it raises any questions :slightly_smiling_face:
retool_generated_api_put.json