Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there a way to get the JSON data sent with a POST request directly inside my post function in my rest resource class?
With the Services module in Drupal 7 I could use file_get_contents("php://input", TRUE) to get the data in my callback, but in Drupal 8 there doesn't seem to be a way to do this.
The data goes into the \Drupal\rest\RequestHandler.php and tries to deserialize and denormalize the data which I would rather just do myself in my post function.
Comments
Comment #2
djcorp10 CreditAttribution: djcorp10 commentedComment #3
cilefen CreditAttribution: cilefen commentedSupport requests are never major priority.
Comment #4
Wim LeersSo you don't want to use the serialization system that Drupal 8 uses (which comes from Symfony btw).
In that case, just write a custom controller. Nothing forces you to use the REST or serialization modules.
Or, alternatively, write a custom serialization implementation. The
hal
module in Drupal core is an example of that.