1si09is001 Posted October 6, 2015 Share Posted October 6, 2015 I am trying to use prestashop web service in order to get the categories name in json format for android but I am facing following problems: 1. I am not able to get the output in json, as it still showing the XML. 2. I don't know how to get List of names of category at a time. can anyone help me out with atleast one example program to retrieve category names. I was trying this in java before implementing it in android try { URL url = new URL("http://www.buyizy.com/api/categories/2?ws_key=QYEFPKCUYMKQF865248P5H2M5RGBXINJ&output_format=json"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (conn.getResponseCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); } BufferedReader br = new BufferedReader(new InputStreamReader( (conn.getInputStream()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } conn.disconnect(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Link to comment Share on other sites More sharing options...
darknessgc Posted October 9, 2015 Share Posted October 9, 2015 Hi, did you try to put the following at the end of you request : &output_format=JSON with the webservice I use , for my android app , I'm using it , it's rocks. :-) Link to comment Share on other sites More sharing options...
zapikoe Posted November 9, 2015 Share Posted November 9, 2015 And the parameter of output_format=JSON is case sensitive Link to comment Share on other sites More sharing options...
Nabahat Posted February 2, 2016 Share Posted February 2, 2016 I am trying to use prestashop web service in order to get the categories name in json format for android but I am facing following problems: 1. I am not able to get the output in json, as it still showing the XML. 2. I don't know how to get List of names of category at a time. can anyone help me out with atleast one example program to retrieve category names. I was trying this in java before implementing it in android try { URL url = new URL("http://www.buyizy.com/api/categories/2?ws_key=QYEFPKCUYMKQF865248P5H2M5RGBXINJ&output_format=json"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (conn.getResponseCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); } BufferedReader br = new BufferedReader(new InputStreamReader( (conn.getInputStream()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } conn.disconnect(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Did it worked for you? Find any other solution to it? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now