16

While making http request to my local wamp server from android emulator I got above error.

// testing on Emulator:
private static final String LOGIN_URL="http:// 10.0.2.2:80/webservice/login.php";

//request:
JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", params);
Ravi K Thapliyal
  • 51,095
  • 9
  • 76
  • 89
sandeep_jagtap
  • 1,484
  • 2
  • 17
  • 24

3 Answers3

30

You have a space at index 7 of your string LOGIN_URL and it is causing the exception. It should be like this.

LOGIN_URL = "http://10.0.2.2:80/webservice/login.php"
Ye Lin Aung
  • 11,234
  • 8
  • 45
  • 51
4

I found the answer:
After googling for couple of hours I found that this kind of error occur due to problem in url
I had extra space in my URL which I removed and I got everything working

    // testing on Emulator:
    private static final String LOGIN_URL = "http://10.0.2.2:80/webservice/login.php";
recnac
  • 3,744
  • 6
  • 24
  • 46
sandeep_jagtap
  • 1,484
  • 2
  • 17
  • 24
  • Consider marking one of the questions as accepted to prevent the SO bot keeping the question up in the top of the list and in the "Unanswered" section. See http://stackoverflow.com/help/accepted-answer – Tseng Aug 18 '13 at 05:13
1

For me it was a new line character at the end of the url String. It wasn't really visible to the naked eye but I caught it with Vi. Pretty dumb error message, not at all helpful.

Vincent Karuri
  • 880
  • 6
  • 4