java.lang.IllegalArgumentException: Illegal character in authority at index 7 while making https request
Asked Answered
O

3

17

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);
Ozzie answered 18/8, 2013 at 4:38 Comment(0)
S
31

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"
Sargassum answered 18/8, 2013 at 4:40 Comment(1)
I had a new line character and after i deleted "\n" it worked fine.Abuttals
O
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";
Ozzie answered 18/8, 2013 at 4:41 Comment(1)
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 stackoverflow.com/help/accepted-answerMarque
D
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.

Dogberry answered 24/2, 2021 at 20:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.