Help

Records not updated with upsert with multiply key fields

Topic Labels: API
2086 4
cancel
Showing results for 
Search instead for 
Did you mean: 
forgeuser
4 - Data Explorer
4 - Data Explorer

Hello! I got unexpected behavior in airtable web api.

I use "Update multiple records" (https://airtable.com/developers/web/api/update-multiple-records) method for update or create records if not exists in my table. I use it with "upsert" parameter with two key fields like ["Handle", "Image Position"]. First one is text, second one is number.

Expected behavior: update records if them exists, otherwise create new. Got behavior: always create new records.

Note that updating with one key field works as expected.

In general we need method to import records to airtable from our internal database and keep them up to date.

4 Replies 4
Risagreene
4 - Data Explorer
4 - Data Explorer

@forgeuser wrote:

Hello! I got unexpected behavior in airtable web api.   mcdvoice

I use "Update multiple records" (https://airtable.com/developers/web/api/update-multiple-records) method for update or create records if not exists in my table. I use it with "upsert" parameter with two key fields like ["Handle", "Image Position"]. First one is text, second one is number.

Expected behavior: update records if them exists, otherwise create new. Got behavior: always create new records.

Note that updating with one key field works as expected.

In general we need method to import records to airtable from our internal database and keep them up to date.


Hello,

The "Update multiple records" method in the Airtable Web API with the "upsert" parameter is designed to update existing records based on the specified key fields and create new records if no matching records are found. However, you mentioned that when using two key fields (text and number), the expected behavior of updating existing records is not occurring, and instead, new records are always being created.

This unexpected behavior might be due to various reasons, such as incorrect key field values, data type mismatches, or API usage errors. To troubleshoot the issue, carefully review the key field values and ensure they match the existing records. Additionally, double-check the data types and the API request payload.

If the issue persists, consider reaching out to Airtable's support or community forums for further assistance. Ensuring the accuracy of key fields and understanding the API's behavior will allow you to import and update records effectively from your internal database to Airtable.

I hope the information helps you.  

 

 

 

foxdealer
4 - Data Explorer
4 - Data Explorer

Based on the search results, it appears that the issue of records not being updated with upsert with multiple key fields is related to a problem with the Airtable web API. According to a post on the Airtable Community forum, some users have experienced unexpected behavior when using the "Update multiple records" feature with upsert and multiple key fields (source: Airtable Community). The issue seems to be related to the way that the API handles updates to records with multiple matching key fields, which can result in some records not being updated as expected.

If you are experiencing this issue, one possible solution is to use a different method for updating records in Airtable, such as the "Update a record" API endpoint or the built-in "Update record" action in Airtable Automations. Alternatively, you can try modifying your API request to use a different set of key fields or to update records individually rather than in bulk. However, it's important to note that these solutions may not work for all cases and may require additional testing and troubleshooting. kdealer login

oliviapaul
4 - Data Explorer
4 - Data Explorer

It would appear, on the basis of the search results, that the problem of records not being updated with upsert when multiple key fields are present is connected to a fault with the Airtable web API. According to a post that was made on the Airtable Community site, a number of users have reported experiencing unexpected behavior when utilizing the "Update multiple records" feature with upsert and multiple key fields (source: Airtable Community). It would appear that the problem is connected to the manner in which the API handles updates to records that contain multiple key fields that match, which can lead to certain records not being changed as anticipated under certain circumstances. https://airtable.com/developers/web/api/update-multiple-records

Using an alternate mechanism for updating records in Airtable, such as the "Update a record" API endpoint or the built-in "Update record" action in Airtable Automations, is one potential solution to this problem. If you are encountering this issue, you may want to consider using this other method. Alternatively, you could try altering your API request to use an alternative set of key fields or to update entries individually rather than in bulk. Both of these suggestions are viable options. On the other hand, it is essential to keep in mind that these remedies could not be applicable in every circumstance and can need for extra testing and examination of the problem. kdealer.com

gabrieljohn
4 - Data Explorer
4 - Data Explorer

When encountering issues with records not being updated during an upsert operation involving multiple key fields, a systematic approach to troubleshooting is necessary. First, meticulously verify that the key fields specified in the upsert operation precisely match the corresponding values stored in the database. Even slight disparities, like variations in case sensitivity or extraneous whitespace, can impede record identification. Additionally, scrutinize database constraints, particularly unique constraints, which may prohibit the update or insertion of records. Ensure that the data types of the key fields align accurately between the upsert operation and the database schema to avoid data type mismatches that can impede record matching. Implement robust transaction handling to encapsulate the upsert operation, guaranteeing atomicity and consistency, especially if multiple database operations are involved. Be vigilant of potential concurrency issues if multiple processes or threads are concurrently executing upsert operations. Employ effective logging and error handling mechanisms to capture and analyze any encountered errors or exceptions, aiding in the identification and resolution of issues hindering record updates during upsert operations. Through this systematic approach, pinpointing and resolving the root cause of records not being updated with upserts involving multiple key fields becomes more attainable.