Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Oct 03, 2017 11:26 PM
Hi all,
I’m having hard time with “sort” through API. Whatever I tried got me INVALID_REQUEST_UNKNOWN error (message: Invalid request: parameter validation failed. Check your request data.)
Here is the browser JS code I render the final request url:
var rUrl = ‘https://api.airtable.com/v0/…/Data?api_key=…’;
rUrl += ‘&filterByFormula=’ + encodeURIComponent(“AND({Pub}=’’,NOT(LEFT({Name},3)=’###’))”);
rUrl += ‘&sort=’ + encodeURIComponent("[{‘field’:‘PID’,‘direction’:‘asc’}]");
Here is the final bundled request I make;
https://api.airtable.com/v0/…/Data?api_key=…&filterByFormula=AND(%7BPub%7D%3D%27%27%2CNOT(LEFT(%7BName%7D%2C3)%3D%27%23%23%23%27))&sort=%5B%7B%27field%27%3A%27PID%27%2C%27direction%27%3A%27asc%27%7D%5D
Removing sort from url always works but I tried many different versions of the sort value as well as different urlencoding/non-encoded versions. What am I doing wrong?
Oct 04, 2017 12:39 AM
Hi there!
The final URL request has to look something like…
&sort[0][direction]=desc
Let me know when you need more. :slightly_smiling_face:
Edit: non-escaped example of course…
Oct 04, 2017 09:11 AM
You can use this to see what the proper URL-encoded parameters for your request should be: https://codepen.io/airtable/full/rLKkYB