Server Code XHR2 won't send POST data

Hi there,

I'm trying to setup a basic login process that connects to a separate server where the logins are stored. We're setting it up with PHP files to receive the communication, do the processing and send back a response. We've used this before in several Jquery projects on Appery, but we're trying to update the process for a new Ionic project.

We were trying to set it up to use Server Code to make the call and handle the response but we can't get it to send any of the POST information. I've confirmed that it is hitting the correct PHP file and can read GETs, but not POST. I've paired it way back to the basic snippet included in Appery out of the box and still get no response.


var url=" -- link to our php file --"

var XHRResponse = XHR2.send("POST", url, {
"parameters": {
"param1": "param1",
"param2": "param2"
},
"headers": {
"Content-Type": "application/json",
"header1": "header1",
"header2": "header2",
},
"body": {
"body1": "body1",
"body2": "body2",
}
});

Apperyio.response.success(XHRResponse.body, "application/json");


And the response we get from the above


{
"status": "error caused by POST fail", // Custom error message -- means the expected POST fields had no data
"POSTed": "", // Displays all POST data
"GETed": "param1param2" // Displays all GET data
}


I've also tried working from the other example off Appery's site here: https://maxkatz.org/2016/03/28/how-to... but that didn't work either. Really confused. Is there another way I'm supposed to send POST information with Server Code?
1 person has
this problem
+1
Reply