Troubleshooting of Airtable API: Difference between revisions

 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
Troubleshooting of Airtable API
Troubleshooting of Airtable API


{{Drafting}}
== How to fix API cache ==
Problems: [https://community.airtable.com/t5/development-apis/api-get-call-not-retrieving-updated-table-field-data/td-p/69002 API GET call not retrieving updated table field da... - Airtable Community]
 
Solution: Example PHP code<ref>[https://stackoverflow.com/questions/15493769/is-there-a-way-to-tell-curl-to-not-use-cache php - Is there a way to tell curl to not use cache - Stack Overflow]</ref>
<pre>
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, "API_URL_HERE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
$headers = [
    'Pragma: no-cache',
    'Cache-Control: no-cache'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 
$response = curl_exec($ch);
if(curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
 
curl_close ($ch);
 
echo $response;
</pre>


== How to fix INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND ==
== How to fix INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND ==
Line 28: Line 52:
* Menu: Edit field
* Menu: Edit field
* Choose the proper data type e.g. switch from "short line text" to "number"
* Choose the proper data type e.g. switch from "short line text" to "number"
* {{exclaim}} If the data type of the field is a number and null values are allowed, you need to convert empty strings {{kbd|key=<nowiki>""</nowiki>}} to {{kbd|key=<nowiki>NULL</nowiki>}} before writing to Airtable.
Example data: Input data of different data types, whether writing to Airtable is successful or the error message received.
<table class="wikitable sortable" style="margin:auto" border="1">
<tr><th title="Field #1">Field value</th>
<th title="Field #2">Instruction of field value</th>
<th title="Field #3">Single line text</th>
<th title="Field #4">Long text</th>
<th title="Field #5">Number (Decimal 1,0)</th>
<th title="Field #6">Number (Integer 2)</th>
</tr>
<tr>
<td>{{kbd|key=<nowiki>""</nowiki>}}</td>
<td>Empty string</td>
<td>ok</td>
<td>ok</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
</tr>
<tr>
<td>{{kbd|key=<nowiki>"0"</nowiki>}} or {{kbd|key=<nowiki>'0'</nowiki>}}</td>
<td>Quoted number</td>
<td>ok</td>
<td>ok</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
</tr>
<tr>
<td>{{kbd|key=<nowiki>0</nowiki>}}</td>
<td>Number without double quote</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>ok</td>
<td>ok</td>
</tr>
<tr>
<td>{{kbd|key=<nowiki>456</nowiki>}}</td>
<td>Integer</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>ok</td>
<td>ok</td>
</tr>
<tr>
<td>{{kbd|key=<nowiki>78.9</nowiki>}}</td>
<td>Number with decimal point</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>INVALID_VALUE_FOR_COLUMN</td>
<td>ok</td>
<td>ok</td>
</tr>
<tr>
<td>{{kbd|key=<nowiki>NULL</nowiki>}}</td>
<td>NULL value</td>
<td>ok</td>
<td>ok</td>
<td>ok</td>
<td> </td>
</tr>
</table>


== How to fix UNKNOWN_FIELD_NAME ==
== How to fix UNKNOWN_FIELD_NAME ==
Line 40: Line 124:
# Verify that the specified field name ("XXX" in this case) exists in the table.
# Verify that the specified field name ("XXX" in this case) exists in the table.
# If it doesn't, ensure you're using the correct field name in your query or action.
# If it doesn't, ensure you're using the correct field name in your query or action.
== How to fix NOT_FOUND or INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND ==
Error message:
<pre>
(
    [error] => NOT_FOUND
)
</pre>
or
<pre>
{
    "error": {
        "type": "INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND",
        "message": "Invalid permissions, or the requested model was not found. Check that both your user and your token have the required permissions, and that the model names and/or ids are correct."
    }
}
</pre>
Solution: Check the URL of API


== Further reading ==
== Further reading ==
* [https://airtable.com/developers/web/api/introduction Introduction - Airtable Web API]
* [https://support.airtable.com/docs/airtable-api-common-troubleshooting Airtable API Common Troubleshooting | Airtable Support]
* [https://support.airtable.com/docs/airtable-api-common-troubleshooting Airtable API Common Troubleshooting | Airtable Support]
* [https://support.airtable.com/docs/field-type-overview Field Type overview | Airtable Support]
* [https://community.airtable.com/t5/development-apis/bd-p/development Development & APIs | Airtable Community]
* Publish Blog version: [https://errerrors.blogspot.com/2023/09/troubleshooting-of-airtable-api-errors.html 解決 Airtable API 常見問題]


== References ==
== References ==