Hi,

I have two routes: one use "POST" the other use "PUT".
In the corresponding controller for the "POST" route, I can get the request body / content with: $request->getContent().

Buuuut for the "PUT" route I try the same eg. $request->getContent() and it always return null.

I have tried a bunch of things, what could I be missing ?

Regards J

Comments

jaypan’s picture

How are you sending the data?

Contact me to contract me for D7 -> D10/11 migrations.

jnorl’s picture

Use Insomnia and curl for testing

curl --request PUT \
--url <endpoint> \
--header 'Authorization: Basic <encoded string>' \
--header 'Content-Type: application/json' \
--data '{
"one": "test",
"two": "more test",
"three": "even more test"
}'

works for post, but not put

drupal 8.9

wombatbuddy’s picture

It looks like the PUT method is not supported, see: https://www.drupal.org/docs/8/core/modules/rest/1-getting-started-rest-c...

jaypan’s picture

Interesting. That page linked to a deeper explanation on the why: https://groups.drupal.org/node/284948

Contact me to contract me for D7 -> D10/11 migrations.