Problem/Motivation
Having entity exposed through the rest module it is currently not possible to update an entity using the JSON format while hal+json does.
This is due to how the denormalizers for those two formats work.
The hal denormalizer extracts the entity form the _links
section, the JSON denormalizer needs the entity type provided in a context array.
The rest module does not provide that context when entities are unserialized.
Proposed resolution
tbd
Remaining tasks
- Write tests that verify that CRUD of content entities works with all serialization formats supported by core
User interface changes
Not UI components involved.
API changes
tbd
Original report by [corvus_ch]
PATCH /node/1
Accept: application/json
X-CSRF-Token: *****-*************************************
Content-Type: application/json
{ "title": [ { "value": "Cras justo odio, dapibus ac facilisis in, egestas eget quam." } ] }
Then I get:
HTTP/1.1 400 Bad Request
Content-Type →application/json
{
"error": "Entity type parameter must be included in context."
}
While this works using application/hal+json (which needs the entity type to be defined in _links section), it does not for json. The JSON denormalizer requires that the entity type is passed in via the context argument.
The RequestHandler
does only provide the request method through the context argument.
Comment | File | Size | Author |
---|---|---|---|
#1 | Bad Pathc.png | 73.39 KB | vivekvpandya |
Comments
Comment #1
vivekvpandya CreditAttribution: vivekvpandya commentedI am also agree with this because once you have already created a node then while updating it should not require to provide type "_links" with hal+json. Only json should work for this purpose.
Comment #2
clemens.tolboom@vivekvpandya your image is not adding information :-(
It would be great to have a script with curl commands added to the issue summary.
[Stock response from Dreditor templates and macros.]
Please update the issue summary by applying the template from http://drupal.org/node/1155816.
Comment #3
corvus_ch CreditAttribution: corvus_ch commentedComment #4
clemens.tolboom@corvus_ch nice work :-)
Do you mind to add the shell commands for this?
See https://www.drupal.org/documentation/modules/rest in particular https://www.drupal.org/node/2098511
Comment #5
clemens.tolboomHmmm ... ain't this a duplicate of #1964034: Pass entity_type into Serializer via context