posting to a server with arguments

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

Answers


With your API URI as given, what happens if you make your arguments actually follow the correct protocol for query string parameters?

http://api.maxchatter.com/75b7bb32e5fc752546263a/devices.json?externalDeviceId=123456789987654321&Platform=windowsphone7


Need Your Help

Does java have built in libraries for audio _synthesis_?

java audio

Note: I do NOT want to "read audio file foo.bar and play it."

UIDynamics not working in Swift

ios objective-c swift

I'm attempting to convert the Ray Wenderlich's tutorial on UIDynamics to swift code, but I'm stuck on the very first part.