我要像創建HttpPost要求:拋出:IllegalArgumentException在Java中URI
http://site/searches.json -d"search[params_attributes[origin_name]=MOW"\ -d"search[params_attributes][destination_name]=IEV"\ -d"search[params_attributes[some]=SOME"
我用手試了一下 - 工作正常。 但我有錯誤:
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 43: http://somesite/searches.json -d"search[params_attributes][origin_name]=KBP"...
at java.net.URI.create(URI.java:776)
at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:79)
它說,錯誤是在第一空間中的位置。 任何想法?
編輯:
我想:
mMethodURI = URLEncoder.encode(mMethodURI, "UTF-8");
並獲得:
Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters.
at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:572)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:292)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
[解決](http://stackoverflow.com/questions/4989743/android-httpclient-and-utf-8) 的問題是在意想不到的地方:) – rocknow 2012-08-10 12:06:05