Member since
09-11-2014
3
Posts
0
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
881 | 09-11-2014 09:51 AM |
09-11-2014
09:51 AM
Figured it out.... Used the Authenticator class, see below public static void main(String[] args) { try { Authenticator.setDefault(new CustomAuthenticator()); URL url = new URL("http://localhost:7187/api/v1/entities?query=type:file&limit=2&offset=10"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line; while ((line = in.readLine()) != null) { System.out.println(line); } in.close(); } catch (MalformedURLException e) { System.out.println("Malformed URL: " + e.getMessage()); } catch (IOException e) { System.out.println("I/O Error: " + e.getMessage()); } } public static class CustomAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { String username = "admin"; String password = "admin"; return new PasswordAuthentication(username, password.toCharArray()); } }
... View more
09-11-2014
09:04 AM
I am using the java.net and java.URL packages, simple code examples to login and make a service call would be helpful
... View more