Skip to content

Creating two related objects in one POST #205

@searls

Description

@searls

This seems quite related to @fivetanley's #202. I'm new to JSON API, so please be gentle with me.

We have a simple example where we'd like to create a Chat object with a single POST, but also embed the first Message in the same request. Whether we "side-post" them or embed them, the question is what the proper way to request they both be created at once and related to one another. An example bit of JSON we imagined POSTing:

{
  "chats": [{
    "messages": [{
      "content": "O HAI"
    }]
  }]
}

And then receive a response like:

{
  "messages": [{
    "id": 2,
    "content": "O HAI",
    "chat_id": 1
  }],
  "chat": {
    "id": 1,
    "message_ids": [2]
  }
}

We've implemented this for ourselves, but we're curious if there's a "right" way per the spec (we searched and weren't able to find it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy