-
Notifications
You must be signed in to change notification settings - Fork 890
Description
At the moment, for server-to-client documents (GET) the JSONAPI content could be:
{"data":null}
(no resource){"data":{}}
(one resource){"data":[]}
(multiple resources)
However, for client-to-server documents (POST, etc.) the JSON content seems to be only be:
{"data":{}}
(one resource)
Section 7.1 tells:
The request MUST include a single resource object as primary data.
However, I would suggest to add support for bulk creation/updating/deletion for the SAME type without using the Atom Operations extension. For this feature the JSONAPI document format does NOT have to change, because []
is already supported by the document parser, but only NOT added as possible value for POST requests. In this case, bulk would be possible using one request. (Eventually {"data":null}
could be supported too for POST requests if for some reason.)
If there will be no errors during bulk, the server could respond with normal status code. If there will be errors, the server could choose to let all resources fail and show the errors or add the valid ones and show errors for the failing ones. In the last case, it maybe should be allowed to use data
next to errors
. (Maybe introduce a new errors
attribute to tell what the server did; maybe: {"partly":true}
. (This could also be a meta thing, so that it is up to the client to handle the partly failing operation.)
I also think this suggestion is compatible with previous versions because of the never remove, only add strategy. As already told, all JSONAPI parsers already support this format.