0

I'm executing the following code:

HttpClient httpclient = new DefaultHttpClient();

HttpResponse response = httpclient.execute(new HttpGet("(...)&avatarUrl={(...)}&socialId=1&sexo=m&username="));

My problem is I'm getting an illegalArgumentException at letter l from the word avatarUrl, and I don't understand why.

I'll really appreciate your help.

Roman C
  • 49,761
  • 33
  • 66
  • 176

2 Answers2

1

Besides the question of ? oder & in your code, there are cleaner ways to pass parameters:

HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
BasicHttpParams params = new BasicHttpParams();

params.setParameter("avatarUrl","...")
      .setParameter("socialId","...")
      .setParameter("sexo","...")
      .setParameter("username","...");

request.setParams(params);

HttpResponse response = httpclient.execute(request);

(not tested, but should work)

Note: I heavily edited my original answer due to a little misunderstanding.

saschoar
  • 8,150
  • 5
  • 43
  • 46
0

Looking at the source code of HttpGet, this exception means that the URL is invalid:

  1. The first query string parameter should be preceded with ?
  2. { and } are not valid characters for URLs and should be escaped
Community
  • 1
  • 1
praseodym
  • 2,134
  • 15
  • 29