I'm trying to create a new resource with an existing template relationship and an address relationship that should become a new resource. Example POST request:
{
"data": {
"type": "post",
"attributes": {
"title": "foo"
},
"relationships": {
"template": {
"data": {
"type": "templates",
"id": "1"
}
},
"address": {
"data": {
"type": "addresses",
"first_name": "John",
"last_name": "Doe"
}
}
}
}
}
Because the address relationship does not contain an ID, it throws the following error:
A resource identifier object MUST contain ['id', 'type'] members.
I get that, because the JSON:API documentation clearly states:
A resource object MUST contain at least the following top-level members:
- id
- type
However, the documentation contains an important exception:
Exception: The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.
That's exactly what I'm doing. Can we create an exception for this, or is this is incorrect way?