RossUK
252
2
Laravel

$request->getContent() is empty

Posted 7 months ago by RossUK

I am trying to inspect the structure of an incoming webhook by capturing the incoming post request to a text file.

here is my api route

Route::post('/callstatus/webhook', '[email protected]');

and here is my controller method

    public function updateStatus(Request $request)
    {

        file_put_contents('temp-log.txt', $request->getContent()->all());
    }

if I make a post request using postman i can access individual post variables by name eg. $request->myField but not the whole request. Am I missing something? :)

I am hoping to see something like the following in my text file

{
    "sid": "SM1f0e8ae6ade43cb3c0ce4525424e404f",
    "date_created": "Fri, 13 Aug 2010 01:16:24 +0000",
} 

I have checked the file is writeable and can write individual values to it.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.