views:

86

answers:

1

I want to send data to server from client(Android), below is my format

http://101.34.45.45/rawData?data={"userId":"guest1","timestamp":"2010-07-01 08:58:23","wifi":[{"ssid":"guest","rssi":"40"},{"ssid":"guest1","rssi":"80"}]}, 

i'm trying series of trial but no use, how this can be done?

A: 

Without your code it is difficult to assess whether you are going through the process correctly, but based on what you've given us, you aren't properly encoding the data. You will need to URL encode the data before appending to the url. To do this in java, use the URLEncoder class (see the javadoc for that class here).

To do this with your code, it would look something like

String url = "http://101.34.45.45/rawData?data=";
String params = URLEncoder.encode("{\"userId\":\"guest1\",\"timestamp\":\"2010-07-01 08:58:23\",\"wifi\":[{\"ssid\":\"guest\",\"rssi\":\"40\"},{\"ssid\":\"guest1\",\"rssi\":\"80\"}]}",  "UTF-8");
url = url+params;
//do the HTTP operation

*Note, for completeness, the W3C and the javadoc advocate not using UTF-8. I used it here simply to generate some sample code.

If that doesn't solve your problem, please post your code so we can see what you're trying to do.

Chris Thompson
thanks bro, this what i looking, working perfectly, thanks alot
Apache