Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Unable to specify depth

default discord avatar
leooo90972 years 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
    tinouti2 years 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
    2 years ago

    Yes, access control is restricting you from reading the document

  • default discord avatar
    leooo90972 years 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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.