
public String readAlertCount(String accessToken, Container container) throws StreamTransformationException{
String response = "";
try {
// SharePoint url to fetch AlertCount List
String wsURL = "https://<org_Shp_Host>/teams/SPdev/AlertsCount/_api/web/Lists/GetByTitle('AlertCount')/GetItemById('21115')";
// Create HttpConnection
URL url = new URL(wsURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
// Set Header
httpConn.setRequestProperty("Authorization", "Bearer " + accessToken);
httpConn.setRequestMethod("GET");
// Read the response.
InputStreamReader isr = null;
if (httpConn.getResponseCode() == 200) {
isr = new InputStreamReader(httpConn.getInputStream());
} else {
isr = new InputStreamReader(httpConn.getErrorStream());
}
BufferedReader in = new BufferedReader(isr);
String responseString = "";
// Write response to a String.
while ((responseString = in.readLine()) != null) {
response = response + responseString;
}
} catch (Exception e) {
response = "Error: " + e.getMessage();
}
return response;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 29 | |
| 25 | |
| 24 | |
| 20 | |
| 14 | |
| 13 | |
| 12 | |
| 11 | |
| 11 | |
| 11 |