It doesn’t work and I always get ERROR 401, and that shouldn’t be the case as I already managed to get the information out of my airtable.
Any ideas why this is happening?
Thank you,
Tiago
Page 1 / 1
Hi @Tiago_Formosinho_San - not sure if Axios is taking care of this for you, but looking at the AT API, I think you need to set the Content-Type header in a POST request (not required in a GET).
curl -v -X POST https://api.airtable.com/v0/APP_ID/Events \
The url would then be https://api.airtable.com/v0/MYAPPID/MailingList
Does it make sense?
I think that should be fine as it is working well for the get
That looks okay but you might try using a table name instead of a view name. I say this only because I’m unsure about Axios requirements - best to eliminate this as a potential cause.
Since you’re getting a 401 are you absolutely sure that the API key of the user with access to the base granted read and write authority? This is unlikely to be the issue, but I always like to ask the obvious because that would cause the behavior you are experiencing - read/GET works, write/POST fails.
Looking at your code above you’ve got:
axios.post(url, config/headers, data)
I think you need:
axios.post(url, data, config/headers)
Thank you! I think the order was the thing that was wrong!
const data = {
"records": r
{
"fields": {
"Name": name,
"Email": email,
}
}
]
}
let url = "https://api.airtable.com/v0/" + app_id + "/" + view
Since you’re getting a 401 are you absolutely sure that the API key of the user with access to the base granted read and write authority? This is unlikely to be the issue, but I always like to ask the obvious because that would cause the behavior you are experiencing - read/GET works, write/POST fails.
Since you’re getting a 401 are you absolutely sure that the API key of the user with access to the base granted read and write authority? This is unlikely to be the issue, but I always like to ask the obvious because that would cause the behavior you are experiencing - read/GET works, write/POST fails.
@snow_jhon, nope the issue was that my axiosConfig was incomplete. ‘Content-Type’: ‘application/json’ needs to be there.
By the way, the reason I was trying to implement this was because I wanted to put a contact from in my blog. I actually wrote about it on this post https://tiagofsanchez.netlify.com/2019-10-06-blog-series-building-a-contact-form-with-airtable/ it anyone is keen to have a read.
Again, thank you for the help.
As a developer you get to create a database with a very nice to use interface.
Thank you! I think the order was the thing that was wrong!
const data = {
"records": c
{
"fields": {
"Name": name,
"Email": email,
}
}
]
}
let url = "https://api.airtable.com/v0/" + app_id + "/" + view