Hi i need to post some data to a web server from windows phone 7 app, i have following url
someurl/devices.json
and i need to send two arguments with it
"externalDeviceId" and "platform" as parameters
can any one let me know how to do it. i have been trying something like this
WebClient client = new WebClient();
client.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadStringCompleted);
client.Headers["Content-Type"] = "application/x-www-form-urlencoded";
client.Encoding = Encoding.UTF8;
string argument = "externalDeviceId=123456789987654321"+"&platform=wp7"
client.UploadStringAsync(new Uri("someurl/devices.json"), "POST", argument);
but i get a web exception in the webClient_UploadStringCompleted callback.
i also tried something like this
soemurl/devices.json&externalDeviceId=123456789987654321&Platform=windowsphone7 but this is not working too get an error 404.
let me know where i am going wrong. this is on windows phone 7.
well it worked, if i comment out the header and encoding line it works
WebClient client = new WebClient();
client.UploadStringCompleted += new
UploadStringCompletedEventHandler(webClient_UploadStringCompleted);
// client.Headers["Content-Type"] = "application/x-www-form-urlencoded";
//client.Encoding = Encoding.UTF8;
string argument = "externalDeviceId=123456789987654321"+"&platform=wp7"
client.UploadStringAsync(new Uri("soemurl
/devices.json"), "POST", argument);
thanks Tetsujin no Oni san for helping … i was going in circles from last one day and just some discussion and it helped fixing this problem
With your API URI as given, what happens if you make your arguments actually follow the correct protocol for query string parameters?