PATCH request to update field via API in table

Hi,

I am using a program to push thru updates to a running database via API. So far, I have been able to search by Username using the filter to return the appropriate ID. I then need to use the ID to locate that record. I am having trouble updating the appropriate field. Can you please show me how I structure the link or the PATCH request? I have tried a variation of the following, to no avail. Please help.

‘{“fields”: { “<>”: “<>” } }’

You can check out Airtable’s excellent REST API documentation here, and it even gives you sample code based on your own data:

1 Like

Thanks I was using that to get as far as I did. However, it’s somewhat vague on how to target fields to update. I am not sure how to structure it. If someone could post an example specifically, that would be great, since their sample doesnt match my situation.

For example:

Your request body should include an array of up to 10 record objects. Each of these objects should have an id property representing the record ID and a fields property which contains all of your record’s cell values by field name. You can include all, some, or none of the field values.

…, Field 6, Field 7, Field 8, Field 9, Field 10, Field 11, Field 12, Field 13, Field 15, Field 16, Field 17 and Field 18 may contain “mention tokens”. A mention token corresponds to a “@mention” in Airtable’s user interface; here in the API it will look like <airtable:mention id="menE1i9oBaGX3DseR">@Alex</airtable:mention> . Mention tokens cannot be created via this API and should be left intact (or wholly removed) when updating long text fields.

Not sure what to do here…Do i include the whole argument there or just a piece? And where do i put the mention?What is the “@Alex” represent in this case?

Welcome to the Airtable community!

What is your level of coding experience? The Rest API documentation is written for developers, and expects the developers to be familiar with programming concepts such as “an array of objects” and “each object should have an id property and a fields property.” The Rest API documentation also includes examples using data from your base.

Do not worry about the “mention tokens” until after you are comfortable creating your API requests. The documentation refers to mention tokens because long text fields can contain them, but they are not necessary. @Alex is just an example of a mention token, where someone tagged a collaborator with that name in the text field.

Thanks! I code with frameworks but have very limited knowledge and tinker more than anything. Like I said, I got some progress haha but am hitting a snag on the fields piece. I don’t see the api docs referencing my use case.

For example, I have username | password fields

I filter and search using a username to locate the ID. Now, I use the ID to get the rows contents, however, I want to update the password for that ID, which is column 2. I don’t see where it shows how to patch column 2 in. I don’t understand what I need to type to get my tool to recognize the request body. It keeps saying csnt find fields.

There are 3 columns of information in the REST API documentation.

In the first column, choose “Update Records” for the table that you are trying to update.

Then, in the 3rd column, it will show you an “EXAMPLE REQUEST” of how you can format your request.

1 Like

Thank you for the help. I see that table and have tried that already, but given my inexperience, I have no clue how to incorporate the data into my framework to override the current data. I have tried several variations but cant get it. It returns {“error”:{“type”:“INVALID_REQUEST_MISSING_FIELDS”,“message”:“Could not find field “fields” in the request body”}}. These are the examples.

–data ‘{
“records”: [
{
“id”: “recRjh1G2jgs3aiU8”,
“fields”: {
“Email”: “----”,
“PW”: “----”
}
},
{
“id”: “recs0tubWSin27dop”,
“fields”: {
“Email”: “----”,
“PW”: “-----”
}
}
]
}’

What app are you using to send the information? You haven’t explained how you’re trying to send this information to Airtable.

You typically don’t send the word “—data”, and you typically don’t use the opening and closing quotation marks around the entire data. That is the raw CURL data that you would use if you were pasting into the command line terminal of your computer.

But instead of using the command line terminal of your computer which can be extremely confusing, I would highly recommend that you download an HTTP/API client such as Postman, Paw, or Insomnia, and work on building your API requests there. All 3 of them also allow you to import the raw CURL data.

I appreciate it! Sorry, I am using browser automation studio (BAS) that has a HTTP Client (I figured most are unfamiliar with BAS). It works well very and simply, likely similar to the ones you posted above. This is how it looks. And honestly, I thank you for actually replying. I know it can be frustrating.

In the URL i enter: https://api.airtable.com/v0/REDACTED/Sheet1/[[ID OF THE RECORD}}
Header: KEY
POST DATA: This is the section I have issues with. I dont know what to put to PATCH the password into the proper field.

That doesn’t look like a very user-friendly app, since it’s just giving you big text boxes to type everything into.

Since you’re just getting started with APIs for the first time, I would highly recommend one of the ones that I recommended above, which helps to guide you through the process better by breaking everything down into smaller pieces.

Import the CURL (or Javascript) from Airtable into one of the apps that I told you about, and it will break it down for you automatically.

2 Likes

OK i will try that out. Thank you so much!!!

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.