I know there are several posts on SO and on many blogs explaining how to get the JSON data that was sent to be read by php. Some use url-encoding, others file_get_contents.
Anyway, it doesn't work for me. I'm sure there is ridiculously easy explanation for it but my code simply doesn't work (the request is sent, the backend answers but that message is more or less always the same: nothing seems to arrive there !
So in my controller I have :
var request_data = {
firstname: 'Quentin',
lastname: 'Hapsburg'
};
$http.post("lib/api/public/blog/post", JSON.stringify(request_data))
.success(function(data) {
console.log(data);
})
And in the php file:
$data = file_get_contents("php://input");
$data = json_decode($data, TRUE);
var_dump($data);
The result is NULL
!
Any suggestions on where my error is ???
EDIT: This might have something to do with the rewriting rules but is not a duplicate since the same answer does not solve this question !