arash moeen
arash moeen

Reputation: 4693

Android URISyntaxException Illegal character in query at index 53

I'm trying to do URI website = new URI(_url) and the _url is like this:

http://www.example.com/mobile/getCategoryChanges?cats=[ {
  "Ts" : 11519972,
  "Token" : "a8015a90e7a84bf58778399043cf79f2"
}, {
  "Ts" : 11519972,
  "Token" : "cf9c027ea4d347d0a74bc90cc82283f0"
}, {
  "Ts" : 11519972,
  "Token" : "39f58aab97c943bc829d5596feb5fbae"
} ]&ts_catList=11519972

when I paste it into the browser it works, but my application can't make a uri from it and throws an exception. How can I fix it properly? THanks

Upvotes: 0

Views: 387

Answers (1)

Dhaval Patel
Dhaval Patel

Reputation: 10299

Give a try to URI class:

String url = "http://www.example.com/mobile/getCategoryChanges";
url = Uri.parse(url).buildUpon().appendQueryParameter("cats",jsonString).build().toString();

Upvotes: 1

Related Questions