【发布时间】:2015-06-18 23:49:31
【问题描述】:
我想要来自 android 中以下链接的 HTTP 请求。我尝试了各种方法将我的 sql 查询添加到我的 URL,但我无法实现。
我认为问题在于 URL 中的“*”(星号)。
<https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22MSFT%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys>?
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = null;
try {
response = httpclient.execute(new HttpGet("https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol in (\"MSFT\")&format=json&env=store://datatables.org/alltableswithkeys"));
} catch (IOException e) {
e.printStackTrace();
}
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK){
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
response.getEntity().writeTo(out);
String responseString = out.toString();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
//..more logic
} else{
//Closes the connection.
try {
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
} catch (IOException e) {
e.printStackTrace();
}
}
错误
引起:java.lang.IllegalArgumentException:非法字符 在索引 50 处查询:https://query.yahooapis.com/v1/public/yql?q=select * 来自 yahoo.finance.quotes 中的符号 ("MSFT")&format=json&env=store://datatables.org/alltableswithkeys 在 java.net.URI.create(URI.java:730)
【问题讨论】:
标签: android httprequest