Closed (fixed)
Project:
Drupal core
Version:
8.1.x-dev
Component:
rest.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Aug 2015 at 16:36 UTC
Updated:
23 Feb 2016 at 12:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
edutrul commentedDone! patch to return entity type & entity id when doing a successful POST
Comment #3
berdirComment #4
nightwalkr commentedI do support this feature! should be included in drupal 8 core
Comment #5
larowlanI think the location header had this info?
Comment #6
berdirOnly if you assume that it contains the entity type/ID and it could be different for some entity types. And you could have aliases, for example...
Comment #7
heilop commentedIt is very interesting, I think in some cases we will need the entity id.
Comment #8
klausiMakes sense, as far as I can see it is allowed to return a body with a 201 response. Should we just return the full newly created entity representation, the same that we would return on GET requests? That way API consumers don't need to learn a new format, they just get the same entity they already know from GET requests.
And this needs a test case, should be added to the POST create tests.
We should also update the comment in the code, which wrongly says that 201 responses are empty.
Comment #9
edutrul commentedThanks a lot @klausi for checking it
ok Added 546216-return-entity-after-post-rest.patch which contains:
Waiting for review/feedback
Comment #10
edutrul commentedComment #12
edutrul commentedPatch from comment #9 failed because I needed to desarialize object in order to compare with $entity_type
Here's patch again with the fix.
Comment #14
-enzo- commentedTest was updated to validate serialized UUID against response UUID, if is the same means the entity was process successfully
Comment #15
-enzo- commentedRemoved extra line
Comment #16
edutrul commentedComment #17
-enzo- commentedComment #18
clemens.tolboomWhitespace
Comment #19
klausiShould be "201 Created responses return the newly created entity in the response body."
Should be "Make sure that the response includes an entity in the body and check the UUID as an example."
Please move the namespaces to "use" statements.
Comment #20
fortis commentedwe already have "use Drupal\Component\Serialization\Json;"
fixed php comments and used Json::decode
Comment #21
fortis commentedwrong comment number in filename, renamed
Comment #25
klausiComments should wrap at 80 characters, see https://www.drupal.org/coding-standards/docs#drupal
same here.
Comment #27
fortis commentedoops, fixed
Comment #28
klausi"response" still fits on the line before, let's use as much of the 80 character line length as possible.
same here, the "the" still fits on the line before.
Comment #30
fortis commentedComment #32
fortis commentedSimpleTest passed
Comment #34
klausiLooks good!
Comment #37
wim leersThis would be a huge win for the REST experience.
Comment #38
wim leersBut probably should go in 8.1.
Comment #39
catchThis needs a change record, so marking needs work for that, but otherwise looks good.
Comment #40
wim leersBetter title too.
Comment #41
wim leersCR created: https://www.drupal.org/node/2665276.
Comment #43
catchCommitted/pushed to 8.1.x, thanks!
Comment #44
wim leersYAY! This is a huge win in terms of RX and perf. Glad to see this in.