gtalarico / pyairtable

Python Api Client for Airtable
https://pyairtable.readthedocs.io
MIT License
765 stars 138 forks source link

Airtable Insert error code 422 #293

Closed ZenonH closed 1 year ago

ZenonH commented 1 year ago

airtable api 422 error Part 2.xlsx

I am getting a 422 Column Data Type error when inserting a record. The value type is correct.

I have been running the code for over 12 months without this error and now I can't figure a workaround.

The current table has 271 headers and 2,773 rows.

Is this a database integrity issue?

Thanks in advance for your time.

mesozoic commented 1 year ago

Can you share the content of the error here in GitHub? Not everyone will be able to open the attachment.

Also, can you let us know what version of the pyairtable library you're using, and whether you recently switched your project from 1.x to 2.0?

ZenonH commented 1 year ago

Hi Alex;

Thanks for your response.

Basically code runs daily, downloads SEC forms, parses out the data then adds the data points from recently issued forms to the table.

The code has run for over 12 ½ months without issue.

The basic problem is the code is now failing to add records to the table. The error messages are not reflecting the actual error causing the 422 error.

I had used the import airtable api with the INSERT method and also your pyairtable version 2 API CREATE method. No difference.

Even if I remove the offending field from the data, the code generates the 422 error on a different field. Also I tried changing the value types to no avail when data type errors are noted.

The API simply is not allowing any new records to be appended to the database and the corresponding error messages are misleading.

And yet I can download the entire table into CSV format without error.

Currently the are 315 field names defined in my data dictionary. Most records are well under the maximum number of fields.

The table has 2,775 records.

I am at a loss on how to proceed.

Regards

Zenon

From: Alex L. @.> Sent: August 7, 2023 1:54 AM To: gtalarico/pyairtable @.> Cc: Zenon @.>; Author @.> Subject: Re: [gtalarico/pyairtable] Airtable Insert error code 422 (Issue #293)

Can you share the content of the error here in GitHub? Not everyone will be able to open the attachment.

Also, can you let us know what version of the pyairtable library you're using, and whether you recently switched your project from 1.x to 2.0?

— Reply to this email directly, https://github.com/gtalarico/pyairtable/issues/293#issuecomment-1667229507 view it on GitHub, or https://github.com/notifications/unsubscribe-auth/ABZAXWSUDMTD6JPWJ7CON6DXUB7HJANCNFSM6AAAAAA3GAS26M unsubscribe. You are receiving this because you authored the thread. https://github.com/notifications/beacon/ABZAXWXTJ4YLRKZ6ZDZ7V4TXUB7HJA5CNFSM6AAAAAA3GAS26OWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTDL7TUG.gif Message ID: < @.> @.>

mesozoic commented 1 year ago

I strongly suspect that either (1) one of your fields has been renamed or changed type, or (2) you're sending data types that a field won't accept (for example, sending strings to a number field). Without being able to see the exact HTTP error message (which should tell you which field(s) have the problem) there's not much more we can suggest. You might take a look at how others have solved 422 errors on the Airtable Community forums.

For now I'm going to close this issue because it appears to be a local issue, rather than a bug in the library. If you don't believe that's the case, please help us by sharing a code snippet which we can use to reproduce the error, along with the specific error text you're receiving. We can reopen this if we have a way to reproduce.

ZenonH commented 1 year ago

Hi Alex L;

Thanks for your prompt replay. I apologize for my belated response.

The frustrating thing about running my code at Airtable is that the code has run without this issue for over 12 months.

Using your API I did add code to respond to each 422 error messages. So when I added code say if str convert to int, I would get another field that can’t be parsed into the database. And on and on and on.

Sometimes the error messages made no sense. I was passing int 0 and the error responded with cannot parse “0”. ??? I since have added to code to delete all null str and int 0 fields. That didn’t help.

At Aittable’s end they have advised me to pass my DICTIONARY key value pairs in quote characters “ ie. ‘key’ should be passed as “key”, etc. However a json.dumps and then json loads does not convert the apostrophes ‘ to quotes “.

I am in a bit of bind of what to do next. Seems I will have to code a CURL subprocess in python to workaround this problem.

Any comment or thoughts you may have will be more than welcomed.

Best regards

Zenon

From: Alex L. @.> Sent: August 7, 2023 11:48 PM To: gtalarico/pyairtable @.> Cc: Zenon @.>; Author @.> Subject: Re: [gtalarico/pyairtable] Airtable Insert error code 422 (Issue #293)

I strongly suspect that either (1) one of your fields has been renamed or changed type, or (2) you're sending data types that a field won't accept (for example, sending strings to a number field). Without being able to see the exact HTTP error message (which should tell you which field(s) have the problem) there's not much more we can suggest. You might take a look at how others have solved 422 errors https://community.airtable.com/t5/search-results/bd-p/search?searchString=422&activeType=all&from=0&sortby=_score&orderBy=desc&pageNo=1&aggregations=%5B%5D&uid=101f6a29-193a-11ed-b8f7-0242ac120006&resultsPerPage=10&exactPhrase=&withOneOrMore=&withoutTheWords=&pageSize=10&language=en&state=2&suCaseCreate=false on the Airtable Community forums.

For now I'm going to close this issue because it appears to be a local issue, rather than a bug in the library. If you don't believe that's the case, please help us by sharing a code snippet which we can use to reproduce the error, along with the specific error text you're receiving. We can reopen this if we have a way to reproduce.

— Reply to this email directly, view it on GitHub https://github.com/gtalarico/pyairtable/issues/293#issuecomment-1668862250 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAXWQAIJV3R2INM2SWTPDXUGZIJANCNFSM6AAAAAA3GAS26M . You are receiving this because you authored the thread. https://github.com/notifications/beacon/ABZAXWRYUCV5FPZY6C5HMXTXUGZIJA5CNFSM6AAAAAA3GAS26OWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTDPDISU.gif Message ID: @. @.> >