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.

Create action is not working as expected with relationships...

default discord avatar
Deleted Userlast year
2

Hi, I am kind of new to PayloadCMS but I struggle to find any resources on, how to send a proper create post for a collection with a relationship, to create both collections at the same time.



Is this even possible?



If I try to send a request with the relationship field in the body having an object as value (containing keys and values that are required as defined in my collection). It just gives me the following error:



"This field has the following invalid selections: [object Object] 0"



Some help on this and maybe some resources would be great!

  • discord user avatar
    dribbens
    last year

    Currently there is not a way to create 2 documents in one request. You'll need to create the first make sure the collection that is being related to is made, then create the parent document with the relationship field populated using the

    id

    of the first document.



    This would be a good feature request if you want to ask for it on our Github in a new discussion.

  • default discord avatar
    Deleted Userlast year

    Thanks

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.