0

I am developing an Android application in which I am trying to send a simple array as a URL parameter, but it is not working properly. I am using a HTTP client and GET method. I have tried this in the following way:

StringBuilder sb = new StringBuilder();
 sb.append(URLEncoder.encode(e.getKey(), "UTF-8")).append('=').append(URLEncoder.encode(e.getValue()+"", "UTF-8"));
where e.getValue() is ArrayList<Integers>

My URL params are appended %5B28%5D when I am sending [28]. If I don't use URL encoder then it goes as [28] But I want to use URL encoder. Am I doing anything wrong?

nilkash
  • 7,408
  • 32
  • 99
  • 176
  • 2
    there is nothing wrong. %5B is [ enconded – Blackbelt Sep 27 '15 at 13:22
  • Yeah there is nothing wrong. But I am not getting proper response. Is there anything require on server side to decode. – nilkash Sep 27 '15 at 13:24
  • Have you tested the url directly on a web browser ? if so, what's the output ? Log the request/response on a debug file on the server. What does it show ? – Pedro Lobito Sep 27 '15 at 13:29
  • I tried same request on rest client. Which also failed to give any output. But if I put simple param then rest client proper result. May there is decode require on server side – nilkash Sep 27 '15 at 13:33

1 Answers1

0

Your code is fine. this is how URL encoding works. Seems like there issue in server at the time of decoding.

Debug the server for any possible issue with decoding.

also refer this answer for a better way of sending an array in get request.

Community
  • 1
  • 1
Rahul Tiwari
  • 6,851
  • 3
  • 49
  • 78