I've set up a subscription, tested my endpoint and all is well. However when I receive a notification of an update to my endpoint the body of the request is blank. I have set the subscription to json body and have also tested with json file as the data type and I still receive no content in the notification other than the header.
I'm responding with 204 in roughly 300ms each time.
Any idea what could be causing a blank notification body?
Answered! Go to the Best Answer.
Best AnswerThanks Samurai Dev. I solved this yesterday as well - I think it was a similar issue.
For future reference for anyone else remember that when receiving a post in express (nodejs) you need to parse the body if it is in json before you can access it.
Best AnswerHaving this problem at the moment as well. $_POST, $_GET and $_FILES are all empty and I have my subscriber set to JSON Body. I get notifications, and the "subscriber stats" page shows that the "payload" for each of the requests is atleast 100 bytes, suggesting that there's SOMETHING there, but I can't find anything.
Best AnswerHave you tried logging the header to see if that's correct? I get the header I'm expecting but the body is missing still - the header could easily account for 100 bytes...
Best AnswerThe header seems to be fine; the reported size on the subscriber details page varies but the header stays the same size, suggesting that it's describing the body content, which for us is blank.
Best AnswerI found out how to get the body, though I'm using PHP so it may or may not apply to you:
$contents = @file_get_contents('php://input');
$_POST, $_GET, $_FILES and $_REQUEST were all blank, but the above had what I was looking for. json_decode'd it to get an array of update objects.
Thanks Samurai Dev. I solved this yesterday as well - I think it was a similar issue.
For future reference for anyone else remember that when receiving a post in express (nodejs) you need to parse the body if it is in json before you can access it.
Best Answer