8000 Creating two related objects in one POST · Issue #205 · json-api/json-api · GitHub
[go: up one dir, main page]

Skip to content
Creating two related objects in one POST #205
Closed
@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

      0