APIs & Integrations

Vazgen_Makaryan
Member

Workflow webhook sends empty request

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!

0 Upvotes
3 Replies 3
Not applicable

Workflow webhook sends empty request

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!

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Workflow webhook sends empty request

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:

Receive JSON POST with PHP

php, json, post
answered by Dom on 08:30AM - 18 Sep 13

Vazgen_Makaryan
Member

Workflow webhook sends empty request

Hi @dadams
Thank you for help it worked

0 Upvotes