Reading Json In Webservice Rest In Android. Filenotfoundexception
Someone know why not works this json in android? urlJson Result is FileNotFoundException, but on the navigator works. edit: public static String readUrl(String urlString) throws E
Solution 1:
Use BufferedReader is not the best method to do this task. Is a lot better use HttpClient with following sample using the library org.json.*;
HttpClienthttpClient=newDefaultHttpClient();
HttpPostpost=newHttpPost("http://www.*****.com/json");
// Execute HTTP Post RequestHttpResponseresponse= httpClient.execute(post);
StringrespStr= EntityUtils.toString(response.getEntity());
JSONArrayrespJSON=newJSONArray(respStr);
Solution 2:
The format is wrong. Use {"name": "string", "...": "..."}
Solution 3:
Problem solved, I'm using spring and I removed this in the service
@RequestMapping(value="/categorias", method = RequestMethod.GET,headers="Accept=application/json")
public @ResponseBody Portada getCategorias() {
to
@RequestMapping(value="/categorias", method = RequestMethod.GET)
public @ResponseBody Portada getCategorias() {
Now works!
Post a Comment for "Reading Json In Webservice Rest In Android. Filenotfoundexception"