I am sending a HTTP request from a C# windowsform application to PHP server hosted on OpenShift (Redhat). I am using the method POST, with Json data.
The problem is that :
- the data seemed to be correctly sent (I see the packets in wireshark)
- the php script is correctly launch and I see in the log that a POST message is received
- but no POST data are beeing received ..
Here is the C# code :
string json = "{\"user\":\"test\"," +
"\"n\":\"2\"}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://........rhcloud.com/webservices.php");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = json.Length;
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Close();
var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
Debug.WriteLine("R : " + result);
}
}
Here is the PHP code :
echo "Start Saving ! ";
// Handle Posted Data From C# App
if (isset($_POST) && !empty($_POST))
{
echo 'Data Recieved';
}
else
{
// Error
echo 'No POST Data Found';
}
The function always return : "Start Saving ! No POST Data Found".
Here is the log line on the server :

Here is the line in wireshark :

Is someone seeing the problem? Do not hesitate to tell me if I am not clear. Could it be Openshift which intercept the data ? Does my php file have a problem?
example.comandexample.commakes redirection towww.example.comand then it won't work