[英]java.lang.IllegalArgumentException: Illegal character in authority at index 7 while making https request
While making http request to my local wamp server from android emulator I got above error.从 android 模拟器向我的本地 wamp 服务器发出 http 请求时,我遇到了上述错误。
// 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);
You have a space at index 7 of your string LOGIN_URL
and it is causing the exception.您的字符串
LOGIN_URL
索引 7 处有一个空格,它导致了异常。 It should be like this.应该是这样的。
LOGIN_URL = "http://10.0.2.2:80/webservice/login.php"
I found the answer:我找到了答案:
After googling for couple of hours I found that this kind of error occur due to problem in url谷歌搜索几个小时后,我发现这种错误是由于 url 问题而发生的
I had extra space in my URL which I removed and I got everything working我的 URL 中有多余的空间,我已将其删除,然后一切正常
// testing on Emulator:
private static final String LOGIN_URL = "http://10.0.2.2:80/webservice/login.php";
For me it was a new line character at the end of the url String.对我来说,它是 url 字符串末尾的换行符。 It wasn't really visible to the naked eye but I caught it with Vi.
肉眼无法真正看到它,但我用 Vi 捕捉到了它。 Pretty dumb error message, not at all helpful.
非常愚蠢的错误消息,一点帮助都没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.