Airtable API Part 4: Update an entry in Airtable

This is part four of our tutorial series on working with the Airtable API in dashdash. To follow along, make sure you’ve completed the previous tutorials.

Overview

So, you know know how to get and create entries in Airtable, the next step is to learn how to update an antry that’s already there. Updating an entry in Airtable is a bit finicky, as we need to use the PUT() function. But don’t worry - the boffins here are dashdash have got you covered.

In this tutorial, we’ll walk through:

  • PUT requests in Airtable (a bit of theory)
  • creating a PUT request to update a single entry

First, let’s set up our PutToAirtable view:

Cell Content
A1 RANGE2JSON
B1 Remove square brackets
C1 Add “fields”
D1 Access URL and ID
E1 PUT request
F2 Update button.
A5 Copy in the entire header row from GetAirtableData, but remove the createdTime header.

PUT requests in Airtable

According to the Airtable API documentation, a PUT HTTP request is “destructive,” by which they mean that when you use PUT, it overrides any fields that are not included in your call.

For example, let’s say we have an entry like this:

And we want to update the Author and Status:

If we send just those two fields, the existing fields will be overwritten in Airtable. Which is probably not what you want when you’re trying to just update something. However, the boffins here at dashdash have a workaround.
When you use the PUT() function, you actually send all the fields, even the ones that you haven’t updated.

So, let’s update the entry we created in Part 3 of the series.

Add the following content to our PutToAirtable view: | Cell | Content |
|------|---------------------------------|
| A8 | My first post from dashdash! |
| B8 | Feature |
| C8 | It’s just easier with dashdash. |
|H8 | Published |

By the end, your view should look something like this:

Now, we can create our PUT request :smile:.

Creating our PUT request

Other than the “update” nature of a PUT request, the only real difference between the PostToAirtable and PutToAirtable views is that we need to add the id of the entry we want to update to the end of our Access URL (see the formula for cell D2 in the table below).

Add the following content to our PutToAirtable view:

Cell Content Description
A2 =RANGE2JSON($B$7:$M$7,B8:M8) Creates our JSON object
B2 =LEFT(RIGHT(A2,LEN(A2)-1),LEN(RIGHT(A2,LEN(A2)-1))-1) Removes the square brackets
C2 =CONCATENATE('{"fields": ',B2,"}") Puts everything in a "fields": object
D2 =CONCATENATE('Setup'!$D$5,"/",A8) Adds the id of the entry to the end of the Access URL, thus indicating to Airtable which entry to alter.
E2 =IF(F2="Update",PUT(D2,'Setup'!$E$2,C2),"") When you click the Update button, it’ll send the PUT request to update your entry

All that’s left to do now is to press the Update button, and then have a look in the data explorer to see the updates!

Summary

And that’s it! You’ve just updated your entry in Airtable.

If you’ve followed this series diligently, you’ll now have the solid fundamentals of working with the Airtable API via dashdash - the rest, well, is up to you :slight_smile:

We can’t wait to see what you create!

Cheers,

The dashdash team

1 Like