Hello guys. I'm using one of my rest API's the structure is simple, only a media field.
Is there any reason for that media field to only have the id instead of the whole object?
When i'm logged in it returns the entire object, when i'm logged out it only returns the id as a string.
i tried passing the depth as a request parameter but like so http://<payload-url>/api/object?depth=15
Do you have any access rules on your media collection?
By default, collections require a user to be logged in to interact with it (
https://payloadcms.com/docs/access-control/overview#default-settings).
I haven't tested this specifically, but it sounds like Payload might return the ID only if you're not allowed to access that specific collection.
Yes, access control is restricting you from reading the document
It was the case thank you. By adding a access: () => true to the Media collection i was able to retrieve the body.
This is not very clear i have to be honest because the collection im querying is accessible even though the relation is not.
Thank you for your help
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.