I created rest resource plugin in a custom module and need to send some JSON data with the request, and access it in the post function. At the moment my post function does not do anything but return some dummy JSON data so I know it is working.

It seems that whenever I try to pass JSON data with the request, it will give me this error: "Could not denormalize object of type , no supporting normalizer found."

If I then try to get this data using file_get_contents('php://input'), it will give me a 403 forbidden error. But if I try to return the same data that I get from file_get_contents('php://input') from the post function, I get the normalizer error again.

I wasn't able to find much information on even making this REST resource and even less on this issue now, so if anyone has any input I would greatly appreciate it, thanks!


1 Answer 1


What has always worked for me when I build custom REST resource plugins for 8 is making the request and payload for the request in HAL+JSON format after activating the format for the endpoint. The return data has always come back as just JSON. Since many times I've already built content entities which have their own GET, POST, PATCH, DELETE operations, I generally build the custom REST resource plugins for custom operations which I create. I've only tested overriding the default core operations a few times and then I had to disable the core's REST endpoint on a specific operation to allow my endpoint to take priority. ie. My POST operation is used rather than the core's. I'm currently using the Beta14 version of 8.

  • So I have tried to use HAL+JSON now, and am no longer getting any errors. But I cannot figure out how to access the data I send in the request inside my REST resource...I know my function is being called, but file_get_contents('php://input') is empty and I don't know where the HAL+JSON data I sent is going.
    – David C
    Commented Aug 26, 2015 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.