I can't seem to access any of the values in my Jive API response. This is what I've got so far, which works. I just need to get the values, but seem to be returning null every time I try to access them. When I iterate the object, I can access the value of the allocated space, ie. single characters as opposed to the value of a key. Please help!
function include(filename) {
var finalRequest = UrlFetchApp.fetch('https://www.cloudconnect.xxx...);
var data = finalRequest.toString().replace("throw 'allowIllegalResourceCall is false.';",
"").trim();
for(i in data){
Logger.log(data);
}
}
If you want to retrieve the key and values by parsing the response value from the URL, how about the following modification?
function include(filename) {
var finalRequest = UrlFetchApp.fetch('https://www.cloudconnect.goog/api/core/v3/contents?count=5&fields=subject,content,links.next');
var data = finalRequest.toString().replace("throw 'allowIllegalResourceCall is false.';", "").trim();
data = JSON.parse(data); // Added
for (var i in data) {
Logger.log("key: %s, value: %s", i, data[i]); // Modified
}
}
var data = finalRequest.getContentText().replace("throw 'allowIllegalResourceCall is false.';", "").trim();
instead of var data = finalRequest.toString().replace("throw 'allowIllegalResourceCall is false.';", "").trim();
.If I misunderstood your question and this was not the direction you want, I apologize.