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

djcorp10 created an issue. See original summary.

djcorp10’s picture

Title: Intercept POSTdata directly from request » Intercept POST data directly from request
cilefen’s picture

Priority: Major » Normal

Support requests are never major priority.

Wim Leers’s picture

Status: Active » Fixed

So 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.