My api has a participants
and an enrollments
resource, where participants have 1 or 0 enrollments. This 1-to-1 is setup in the database such that enrollments table shares a primary key with the participants table. In the case where a participant already exists and the user is trying to add an enrollment to that participant, what must the api support?
Clearly this should work:
POST /participants/123/enrollment
{
"type": "enrollments",
"attributes": {}
}
And this should probably work too:
POST /enrollments
{
"type": "enrollments",
"attributes": {},
"relationships": {
"participant": {
"id": "123",
"type": "participants",
}
}
}
But I’m not sure about if the server needs to accept something like:
POST /enrollments
{
"type": "enrollments",
"id": "123",
"attributes": {}
}
The specification is pretty clear when the id is client generated, but i’m not sure this falls into that situation.