Mr Nice
Mr Nice

Reputation: 524

Unable to get data from server if url having hyphen,in android

I am sending request to server by using this following url format
http://api.xyz.com/JSonService.asmx/Category_Name=food-and-drink.

But my problem is i am not able to send the request as hyphen present in food-and-drink,but in my system browser it is working fine..

Thanks in advance.

Upvotes: 2

Views: 2349

Answers (1)

Padma Kumar
Padma Kumar

Reputation: 20041

You need to use URLEncoder

String queryStr = URLEncoder.encode("food-and-drink", "utf-8");
String urlStr = "http://api.xyz.com/JSonService.asmx/Category_Name=" + queryStr;

Upvotes: 1

Related Questions