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:
/api/categories?populate=parent&filters[parent][$null]=true
/api/categories?populate=parent&filters[parent][id][$lte]=0
/api/categories?populate=parent&filters[parent]=null
/api/categories?populate=parent&filters[parent][id][$eq]=null

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