[API] Formula filter for linked records not returning any results


#1

I have the base https://airtable.com/shrk4QtqMfI5yJdYr with two tables: Posts and Categories; The Posts table has one column which is a link to Categories and another which is a lookup on Categories.

The data is as follows:

{
    "records": [
        {
            "id": "rec0Wx3tdBsuBjHrV",
            "fields": {
                "Name": "Post 1",
                "Categories": [
                    "rec7PDGo7c2GP9wu2"
                ],
                "Category names": [
                    "Category 1"
                ]
            },
            "createdTime": "2018-11-22T20:24:15.000Z"
        },
        {
            "id": "rec334VYelorur9Ix",
            "fields": {
                "Name": "Post 3"
            },
            "createdTime": "2018-11-22T20:24:15.000Z"
        },
        {
            "id": "recIJhElGuUrFdvVn",
            "fields": {
                "Name": "Post 2",
                "Categories": [
                    "rec7PDGo7c2GP9wu2",
                    "reccMvdKsHB36MN3A"
                ],
                "Category names": [
                    "Category 1",
                    "Category 2"
                ]
            },
            "createdTime": "2018-11-22T20:24:15.000Z"
        }
    ]
}

The following request returns only record rec0Wx3tdBsuBjHrV (it should return rec0Wx3tdBsuBjHrV and recIJhElGuUrFdvVn since both have “Category 1”):

https://api.airtable.com/v0/appLEqjgwtfud3r86/Posts?filterByFormula={Category names}='Category 1'

And this request returns no results at all:

https://api.airtable.com/v0/appLEqjgwtfud3r86/Posts?filterByFormula={Categories}='rec0Wx3tdBsuBjHrV'

Although it clearly should return at least one.


#2

Has this been solved? I am having the same issue.


#3

Hi,
From my understanding of the API you cannot retrieve linked records using filterByFormula. That is not the purpose of it. filterByFormula is used to sort/filter record data in the target table. So filtering by a field in another table isn’t going to work. You could, I suppose, filter by the linked column using the actual record IDs that is saved in the column but I have never tried that.

I work with the API extensively and have written a tutorial on how to get linked records using the API.
You can check it out and let me know if it helps.