0

I am newbie developer in Java. STEP 1 I have already done the the following:

  1. Logged in to REST API server (with login&password)
  2. Received a token in XML format which i parsed with SAX parser so now i am in a position of a token. Below is the sample code for Login:

Java code:

 String url1 = "https://api4.liverail.com/login";
 URL obj = new URL(url1);
 HttpsURLConnection con1 = (HttpsURLConnection) obj.openConnection();
 String urlParameters ="username=paania@gmail.com&password=d372a15b714bd250e";
 con1.setDoOutput(true);
 con1.setRequestMethod("POST");
 DataOutputStream wr = new DataOutputStream(con1.getOutputStream());
 wr.writeBytes(urlParameters);

STEP 2: I want to pass the token to REST API to obtain some information e.g a list from category but when i send the request via GET method , i get a response in XML saying [CDATA[You need to be logged in]] This is the code in Java:

String url =  "http://api4.liverail.com/advertising/category/list/?token="72938howdwoi";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(newInputStreamReader(con.getInputStream()));
in.close();
con.disconnect();

I am not sure what i am missing here.

Any suggestions?

mapa
  • 39
  • 10

1 Answers1

0

Just changed your url for request of data :

String url =  "http://api4.liverail.com/advertising/category/list/?token=72938howdwoi";
Vimal Bera
  • 10,346
  • 4
  • 25
  • 47