title: How to make REST API call using a token?
body: <p>I am newbie developer in Java. STEP 1 I have already done the the following:</p>
  
  <ol>
  <li>Logged in to REST API server (with login&amp;password)</li>
  <li>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:</li>
  </ol>
  
  <p>Java code:</p>
  
  <pre><code> String url1 = "https://api4.liverail.com/login";
   URL obj = new URL(url1);
   HttpsURLConnection con1 = (HttpsURLConnection) obj.openConnection();
   String urlParameters ="username=paania@gmail.com&amp;password=d372a15b714bd250e";
   con1.setDoOutput(true);
   con1.setRequestMethod("POST");
   DataOutputStream wr = new DataOutputStream(con1.getOutputStream());
   wr.writeBytes(urlParameters);
  </code></pre>
  
  <p>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 <code>[CDATA[You need to be logged in]]</code> This is the code in Java:</p>
  
  <pre><code>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();
  </code></pre>
  
  <p>I am not sure what i am missing here.</p>
  
  <p>Any suggestions?</p>