Unable to specify depth

default discord avatar
leooo
2 months ago
3

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

  • default discord avatar
    tinouti
    2 months ago

    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.

  • discord user avatar
    jarrod_not_jared
    Payload Team
    2 months ago

    Yes, access control is restricting you from reading the document

  • default discord avatar
    leooo
    2 months ago

    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

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.