Feb 06, 2021 04:06 AM
I’m trying to access the metadata but I keep getting a 404 error.
I have a feeling that the problem is with the headers.
headers = {
"Authorization":"Bearer My_User_API",
"X-Airtable-Client-Secret": "Meta_Secret_Token"
}
response=requests.get("https://api.airtable.com/v0/meta/bases/My_BaseID/tables", headers=headers)
# I also tried
response=requests.get("https://api.airtable.com/v0/meta/bases", headers=headers)
Any ideas?
Feb 07, 2021 07:56 AM
Both of those requests look fine. I’m not sure about Python specifics, you can try the same with curl in your terminal to help isolate the issue:
curl "https://api.airtable.com/v0/meta/bases/appXXXXXXXX/tables" \
-H "Authorization: Bearer keyXXXXXXXXXXX" \
-H "x-airtable-client-secret: yourorg-XXXXXXXXXXXXXXXXXX"
Note HTTP header names are case insensitive. If that curl requeset works for you, then you know it’s something with the Python wrapper/lib you’re using.
Feb 08, 2021 12:15 AM
Thanks for the response. I am still getting {“error”:{“type”:“NOT_FOUND”}} with CURL.
My client secret key does not start with yourorg-xxxx though it’s just bdTxxxxxx
The client secret key is the Meta API key right?
Is it possible to reset it? I’m 100% sure I’ve copied it correctly?
Feb 08, 2021 11:10 AM
Hey @Peter_Stavrou – got it, totally possible they changed the format of the client secret key.
Indeed, the client secret key is the Meta API key.
It 404s on both /v0/meta/bases
and on /v0/meta/bases/My_BaseID/tables
? Because my next suspicion is just that My_BaseID
might be wrong (grab this ID from either the /v0/meta/bases
endpoint or via examples at airtable.com/api)
Feb 08, 2021 02:11 PM
Both give me 404 which confirms that BaseID is not wrong.
Feb 08, 2021 05:07 PM
If you don’t mind using all Python code (and skipping curl), this is some sample code I put together to test the API:
----------------------------------------------
# 2021-02-02 v0.01 runs under Python 3.9 (should work with 3.5+)
# from airtable import Airtable # you might need to include this (I didn't have to)
from airtable.auth import AirtableAuth
import requests
import json
API_KEY = 'keyABCDEF01234567' # your API key
BASE_KEY = 'appABCDEF000111' # base key with the tables to list
CLIENT_SECRET = "pythonorg-000123abcdef" # sample secret for 'python org' company
auth_info = AirtableAuth( API_KEY )
meta_hdr = {"X-Airtable-Client-Secret": CLIENT_SECRET }
resp = requests.get( "https://api.airtable.com/v0/meta/bases/"+ BASE_KEY +"/tables",
auth=auth_info, headers=meta_hdr)
table_dict = json.loads( resp.text )
for tbl in table_dict[ 'tables' ]:
print( tbl['name'] )
----------------------------------------------
I hope that helps to get you started.
jd
Feb 08, 2021 05:32 PM
Thanks heaps jd!
I’m still getting 404 error so I’m guessing there is an issue with my keys.
I’ll follow this up and try your code afterwards.