How do I get HTTP Request body content in Laravel? How do I get HTTP Request body content in Laravel? xml xml

How do I get HTTP Request body content in Laravel?


Inside controller inject Request object. So if you want to access request body inside controller method 'foo' do the following:

public function foo(Request $request){    $bodyContent = $request->getContent();}


You can pass data as the third argument to call(). Or, depending on your API, it's possible you may want to use the sixth parameter.

From the docs:

$this->call($method, $uri, $parameters, $files, $server, $content);


For those who are still getting blank response with $request->getContent(), you can use:

$request->all()

e.g:

public function foo(Request $request){   $bodyContent = $request->all();}