How to create an entity with relation

Hi there, i’m going a little crazy over this and it’s hard for me to understand why i can’t find any good resource on the web about this. Maybe i have a completely wrong perspective and understanding about all this.

I have a collection called: houses.
I can create new Houses with doing a POST Request against
http://localhost:1337/api/houses

with some data like

{
  "data": {
    "uid": "",
    "size": "big"
  }
}

So far so good.

But now i’ve added a field to the houses collection, that’s called owner which has a many-to-one relation to a new field in the Users Collection (users_permissions_user).

How do i create houses that have the relation and adds a owner to a house? The docs say that a relations field first of all is a normal field, which would let me think that something like

{
  "data": {
    "uid": "",
    "size": "big",
    "owner": 1
  }
}

Should work. But it just doesn’t. What am i missing here?
I appreciate any help on this.

Okay i figured it out. The issue here lies in the permissions. I needed to add the find permission to the authenticated users in order to make this work. I don’t quite understand why, but it’s working now.

2 Likes