-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserializing a Resource Object/Relationship on create throws an error when no ID is provided #21
Comments
Any workaround on this? |
I think this would need handling in jsonapi-parser
That said, I don't think you can create the related object like that in json-api. Batching / multiple creations at once seems to be work-in-progress for the spec: So you'll want to work around that somehow by going off-spec. That doesn't help with this lib but it makes it less likely to get "fixed" here. Regarding terminology and the creation optional ID thing, the error message is talking about "resource identifier objects", so let's see what those are. http://jsonapi.org/format/#document-resource-identifier-objects says it needs id and type and doesn't have any get-outs for creation. So what does permit creation without an ID? You've got attributes for a new record in the relationship data. What goes in there? So while perfectly sensible to want to create them together, it looks like you'll need to create one then the other, 2 requests, or modify your api endpoint to take attributes for the other models and create them on the side, so putting them in the "post" payload instead of in the related address model without an id. |
I'm trying to create a new resource with an existing
template
relationship and anaddress
relationship that should become a new resource. Example POST request:Because the
address
relationship does not contain an ID, it throws the following error:I get that, because the JSON:API documentation clearly states:
However, the documentation contains an important exception:
That's exactly what I'm doing. Can we create an exception for this, or is this is incorrect way?
The text was updated successfully, but these errors were encountered: