Jump to content

1si09is001

Recommended Posts

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 {
 
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

  • 5 weeks later...
  • 2 months later...

 

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 {
 
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...