I am trying to debug HTTP POST data sent to some AJAX PHP in Eclipse PDT and it is new to me, so I am probably making some very basic mistake.
I found what seems to be an excellent Chrome browser plugin: PostMan
I have defined my request thus:
Which is trying to emulate my AngulrJs code (which works)
var postData = { userName: $scope.registrationData.userName,
email: $scope.registrationData.email,
password: forge_sha256($scope.registrationData.password)
};
var url = HOST + 'api/register.php';
$http.post(url, postData)
If I just use the AngularJs from a browser page, it works and the PHP returns what I expect it to.
BUT, when I use Postman, then in my PHP code
$postData = file_get_contents("php://input");
$request = json_decode($postData, true);
I find that $_POST
is empty.
What am I doing wrongly (or is there a simpler way to debug HTTP Post with Eclipse PDT)?
[Update] Thanks, @Rubelet, for pointing out that the POST data should go in the body, not the headers.
If I encode it as form data
the received POST data is still empty. I am guessing that I should use "raw", but how do I encode? As JSON?