So on my client (windows phone 8.1 app) I have posted a JSON just for testing, here is the code for this:
public async void SendJSON()
{
try
{
string url = "http://posttestserver.com/post.php?dir=karim";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "text/plain; charset=utf-8";
httpWebRequest.Method = "POST";
using (var stream = await Task.Factory.FromAsync<Stream>(httpWebRequest.BeginGetRequestStream,
httpWebRequest.EndGetRequestStream, null))
{
//create some json string
string json = "{ \"my\" : \"json\" }";
// convert json to byte array
byte[] jsonAsBytes = Encoding.UTF8.GetBytes(json);
// Write the bytes to the stream
await stream.WriteAsync(jsonAsBytes, 0, jsonAsBytes.Length);
}
}
catch(Exception ex)
{
}
}
Now I'm trying to figure out, from the www.myurl.com how would I retrieve what has been posted from the mobile app using a Web Service?
UPDATE
When I debug these lines, it runs perfectly without breaking nor falling within the catch. However when looking at where it should post to (the results are here http://www.posttestserver.com/data/2015/12/14/karim/) it doesn't post anything.
Does anyone know what I'm doing wrong?
BTW: it already has results there because I have done this directly from my desktop.