Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget_subusers.java
More file actions
Latest commit
37 lines (28 loc) · 1.19 KB
/
Copy pathget_subusers.java
File metadata and controls
37 lines (28 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
importjava.net.HttpURLConnection;
importjava.net.URL;
importjava.net.URLConnection;
importjava.util.stream.Collectors;
publicclassget_subusers {
publicstaticvoidmain(String[] args) throwsIOException {
// Details retrieved from the Authentication part.
StringuserId = "";
Stringtoken = "";
URLurl = newURL("https://api.decodo.com/v1/users/"+userId+"/sub-users");
URLConnectionconnection = url.openConnection();
HttpURLConnectionhttpConn = (HttpURLConnection) connection;
httpConn.setRequestProperty("User-Agent", "Mozilla/5.0");
httpConn.setRequestProperty ("Authorization", "Token "+token);
httpConn.setRequestMethod("GET");
if (200 <= httpConn.getResponseCode() && httpConn.getResponseCode() <= 299) {
BufferedReaderbr = newBufferedReader(newInputStreamReader(httpConn.getInputStream()));
System.out.print(br.lines().collect(Collectors.joining()));
} else {
BufferedReaderbr = newBufferedReader(newInputStreamReader(httpConn.getErrorStream()));
System.out.print(br.lines().collect(Collectors.joining()));
}
httpConn.disconnect();
}
}