Query Where Relationship Does Not Exist

System Information
  • Strapi Version: 4.3.0
  • Operating System: Ubuntu
  • Database: mysql 8
  • Node Version: 16.16.0
  • NPM Version: 8.11.0
  • Yarn Version:

How do I use the rest api to query for results of items that do not have a relationship. I am trying to find categories that do not have a parent category.
Here is what I have tried that did not work:

I either get no results or an error: “Only $and, $or and $not can only be used as root level operators. Found $null.”

Any help would be great, thanks!

1 Like

Got the same error. Do you got answer?

found solution

Try this - it might work. I still have doubts on the way this feature works.


In my case, I figured that it works the opposite way of how it’s supposed to work.

If I am looking for “null” values it should be “…[$null]=true”. However, the api fetched records that are not “not null” (in the “parent” field in this example).

PS: I am using Strapi 4, FYI.