httprequest - Http Request with adding sql query android -
i want http request below link in android. have tried various ways add sql query url can't make happen.
i think problem '*' (star) in 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 * yahoo.finance.quotes 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 connection. try { response.getentity().getcontent().close(); throw new ioexception(statusline.getreasonphrase()); } catch (ioexception e) { e.printstacktrace(); } }
error
caused by: java.lang.illegalargumentexception: illegal character in query @ index 50: https://query.yahooapis.com/v1/public/yql?q=select * yahoo.finance.quotes symbol in ("msft")&format=json&env=store://datatables.org/alltableswithkeys @ java.net.uri.create(uri.java:730)
change asterisk "%2a". asterisk character reserved special uses in urls.
"...select%20%2a%20from%20yahoo....."
Comments
Post a Comment