I am currently working on an Alexa skill using AWS Lambda, and all has been working perfectly except for one thing. I can't seem to successfully POST HTTP param's / custom headers to my server. It can grab pull the information perfectly, but I cannot figure out why it is not sending the parameters / custom headers.
My code for sending a HTTP POST request looks like this :
function httpGetMall(latitude, longitude, callback) {
var options = {
host: 'myserver.com',
path: '/path/to/script.php',
auth: 'myAuthenticationPassword'.toString('base64'),
method: 'POST',
headers: {'latitude': latitude.toString(), 'longitude': longitude.toString()}
};
var req = http.request(options, (res) => {
var body = '';
res.on('data', (d) => {
body += d;
});
res.on('end', function () {
callback(body);
});
});
req.end();
req.on('error', (e) => {
});
}
I know for a fact the function is being called correctly, as it returns the data on callback perfectly.
On my php script, I am attempting to grab the values like so :
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
I have tried manually setting the latitude and longitude inside the function to see if they were not getting passed in, but the server still never received them.
Any help would be greatly appreciated. Thanks!