Reputation: 1334
I am trying to query a spreadsheet with gviz (Google Visualization), using UrlFetchApp, but no result so far.
Could you help me to fix this code?
(the query Url works fine in the browser)
function queryTest() {
var onlyforscope = SpreadsheetApp.getActiveSpreadsheet();
var template = "https://docs.google.com/spreadsheets/d/%s/gviz/tq?gid=%s&tq=select C,E,K,M,N,O where C contains '%s'";
var query = Utilities.formatString(template, docId, sheetId, value);
var param = {
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
};
var r = UrlFetchApp.fetch(query, param).getContentText();
// var j = JSON.parse(r);
Logger.log(r);
return;
}
Thanks in advance, Fausto
Upvotes: 4
Views: 504
Reputation: 1334
it was trivial, though hard to find out for me
the required scope is Drive !!!
I just add this line and it worked
var onlyforscope = DriveApp.getRootFolder();
Upvotes: 4