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

default discord avatar
magiique
2 months ago
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
    Payload Team
    2 months ago

    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
    magiique
    2 months ago

    Thanks

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.