I am using the example from the GET request to the Domino Data Service below. I changed the URL: to access a database on my server. I tested the URL and made sure that it actually returns JSON data and it works. But when I run the code below it does not return any data.
I cannot seem to get to the data. What am I doing wrong? Also, if I append the URL with/unid/<unid of the view> the conn returns 404. But if I test the same URL in another browser window it returns data.
Also, is it possible to bind this to an objectData type?
// Establish connection with Domino database collection resource
var url = new java.net.URL("http://ibm-z0shi2lw4cz.swg.usma.ibm.com:80/api/data");
var conn:java.net.HttpURLConnection = url.openConnection();
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() == "200") {
// Get the response
var reader = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream()));
var buffer = new java.lang.StringBuffer();
var line = "";
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
reader.close();
// Create array from response
var jsonarray = eval('(' + buffer + ')');
// Get filenames and titles from Domino database collection resource
// On XPage, requestScope.status is bound to a multi-line text control
for (var i = 0; i < jsonarray.length; i++) {
requestScope.status += jsonarray [i].@filepath + " - " + jsonarray [i].@title + "\n";
}
} else {// if connection fails
requestScope.status = conn.getResponseCode() + " " + conn.getResponseMessage();
}
Thank you,