Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Nov 22, 2018 12:18 PM
The following request works as expected:
https://api.airtable.com/v0/appD1JKW7PlQhRMrF/Docentes?fields=Email&fields=Status
But this one fails with status 422 Unprocessable Entity:
https://api.airtable.com/v0/appD1JKW7PlQhRMrF/Docentes?fields=Email
The response is:
{"error":{"type":"INVALID_REQUEST_UNKNOWN","message":"Invalid request: parameter validation failed. Check your request data."}}
Nov 22, 2018 12:22 PM
Also, what does “array of strings” actually mean in the context of an URL-encoded parameter?
Nov 22, 2018 01:20 PM
Funny thing, repeating the field works:
https://api.airtable.com/v0/appD1JKW7PlQhRMrF/Docentes?fields=Curso&fields=Curso
Clearly there’s a problem with the “array” when it has only one element.
Mar 03, 2019 03:10 AM
Yes, I don’t understand the “array of elements” when it doesn’t work for one element. Airtable should explain it better in the doc
Mar 04, 2019 03:07 PM
You’re right—this is a little confusing.
If you want to pass a single value, such as maxRecords
, you’ll supply it as a normal query parameter. For example:
?maxRecords=5
However, if you want to pass an array, you’ll need to append []
to the end of each key.
For example, imagine you want to list records and only include two fields: “My First Field” and “My Other Field”. You’d send query parameters like this:
?fields%5B%5D=My%20First%20Field&fields%5B%5D=My%20Second%20Field
If you only wanted one field, you’d still append the []
.
Our query parsing is somewhat lenient, which is why supplying the parameter multiple times works. We recommend appending the []
in all cases so that it works when you just want to supply an array with one value.
If you can, we recommend using a client library to avoid some of this. Airtable.js is our official offering, but our API docs mention a few unofficial libraries for other languages. You can use the Airtable API URL Encoder to put together a properly-formatted request if you’re not using a library.
In any case, we’ll plan to update our docs here, because this isn’t clear.
May 04, 2020 05:28 AM
So, this is getting pretty annoying at the moment, as it is taking me almost two days to just configure airtable post request, i have tried everything ii know and have researched online, nothing seems to change, getting the same error almost all the time
Home.js:90 POST https://api.airtable.com/v0/app5aBFbyn7WropZL/contact?api_key=keyfX7UkMiODjA6fq 422 (Unprocessable Entity)
sendData @ Home.js:90
Home.js:103 Success: {"error":{"type":"INVALID_REQUEST_UNKNOWN","message":"Invalid request: parameter validation failed. Check your request data."}}
My code
`
import React, { Component, useState } from “react”;
import axios from “axios”;
import AboutUs from “…/…/component/AboutUs”;
import { Form } from “react-bootstrap”;
import Contact from “./Airtable”;
var Airtable = require(“airtable”);
var base = new Airtable({ apiKey: --------------" }).base(
“app5aBFbyn7WropZL”
);
}
const [formData, setFormData] = useState({});
const [message, setMessage] = useState("");
const handleInput = (e) => {
const copyFormData = { …formData };
copyFormData[e.target.name] = e.target.value;
setFormData(copyFormData);
};
base(“contact”).create(
[
{
fields: {},
},
{
fields: {},
},
],
function (err, records) {
if (err) {
console.error(err);
return;
}
records.forEach(function (record) {
console.log(record.getId());
});
}
);
const sendData = async (e) => {
e.preventDefault();
try {
const response = await fetch(
“https://api.airtable.com/v0/app5aBFbyn7WropZL/contact?api_key=----------------”,
{
method: “post”,
body: JSON.stringify([formData]),
headers: {
“Content-Type”: “application/json”,
},
typecast: true,
}
);
const json = await response.json();
console.log(“Success:”, JSON.stringify(json));
setMessage(json.message);
} catch (error) {
console.error(“Error:”, error);
setMessage(“Error”);
}
};
return (
Slack-Larsseit "Helvetica Neue", "Helvetica","Segoe UI",Tahoma,Arial,sans-serif
, <br />
<span
style={{
textAlign: "justify",
maxWidth: "29rem",
fontSize: "11px",
}}
>
{/* onChange={this.changeHandler} */}
<input type="checkbox" /> i would like to receive email
notifications about OneScrin and its affilliate products. By
clicking 'Sign Up', you understand and agree to the OneScrin{" "}
<a href="https://onescrin.com.ng/terms-of-service">
Terms of Service
</a>
</span>
<div>{message}</div>
</div>
</div>
</div>
<div
className="header-hero-image d-flex align-items-center wow fadeInRightBig"
data-wow-duration="1s"
data-wow-delay="1.1s"
>
<div className="image">
<img src="assets/images/home.gif" alt="Chat Room" />
</div>
</div>
</div>
<AboutUs />
<Contact />
{/* <PostLanding /> */}
</header>
</div>
);
};
export default Home;
`
Oct 05, 2020 01:54 PM
How does one do this in Python?
I tried
AT_url = 'https://api.airtable.com/v0/'+ base_id + '/' + table_id + '/' + record_id
AT_url += '?fields=Notes'
response = requests.get(AT_url, headers=read_headers)
and that errored out with the same INVALID_REQUEST_UNKNOWN error Michael_Cetrulo had.
I’ve also tried:
AT_url += '?fields=Notes&fields=Notes'
and
AT_url += '?fields%5B%5D=Notes'
and
AT_url += '?fields%5B=Notes%5D'
but none work.
I’m sure it’s just some formatting issue I’m getting wrong, but I can’t figure it out…
In addition, I’d like to future proof it and use the field ID. Once I have the field query fixed, would the field ID just be used in place of the field name?
Oct 05, 2020 04:27 PM
@Tane_Martin
In Python my url looks like this:
https://api.airtable.com/v0/base_id/table_name?api_key=APIKEY
Then I pass the response to a Panda dataframe, where I can work with the data via python directly for that specific table.
Oct 05, 2020 05:11 PM
Thanks @CH3V4L13R, but my issue is more with pulling the data only for that record and field. The problem is that my table is large enough and has enough data that the call will fail if I don’t filter it (i think the limit is 6MB). I also dont want to burden the server too much, pulling the full table for just the single cell I’m interested in. Do you have any experience filtering down to the record and/or field level in a Python call?
Also, if requesting a field using a field ID, does anyone know if the value returned keyed by the field ID? Or the field name? If it’s still keyed by the field name, that’d be a bummer since I’d have to map it back out again.
Oct 05, 2020 05:41 PM
You don’t need to pull the full table, only the record that you are interested in.
Do a request on this url:
https://api.airtable.com/v0/APP_ID/TABLE/RECORD_ID?api_key=APIKEY
Send that response to PANDA so you can manipulate all your fields via Python directly.