Workflow webhook sends empty request


#1

Hello Dear guys
I am trying to use workflow webhooks.I can successfully test them with requestbin however on my server i get an empty POST request
Here is my code
if (!empty($_POST))
{
$file = file_put_contents( ‘log.txt’,‘Post!’);
}
elseif (empty($_POST)) {
$file = file_put_contents( ‘log.txt’,‘empty’);
}
else {$file = file_put_contents( ‘log.txt’,‘else!’);}

Please help me!


#2

Hi @Vazgen_Makaryan

The $_POST variable won’t include JSON data, so you’ll need to read the raw input stream.

$data = file_get_contents(“php://input”);

More details are here:


#3

Hi @dadams
Thank you for help it worked


#4

I just stumbled upon this topic while searched for a solution for the exact same problem. Thank you very much!

I must note that it doesn’t say anything that the request data is being transferred by JSON in the official documentation. Plus, using requestbin to test our webhooks is redundant since the request from HS itself is not within the POST superglobal. I suggest adding that to the docs.

Cheers!