Support the ongoing development of Laravel.io →
posted 5 years ago

Hey guys,

The class \Illuminate\Foundation\Testing\Concerns\MakesHttpRequests is used by Laravel in test cases so you can test and endpoint (like $this->post) the bug I am facing is that if I call $request->getContent(); in my controller it will return empty string. This only happens in test environments. Normal behaviour of Laravel requests is that getContent will return the raw body of the request.

So to sum up: Request::getContent returns empty string in test environment, but raw body of request in live environment.

Does anybody know how to get the raw body of a request in test environment?

Ref: https://github.com/laravel/framework/issues/31303

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

esbenp esbenp Joined 11 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.