With this script I would to put the CSV in a specific Sheet named "TEST".
I have tried with getSheetByName but without result.
How could I proceed?
function importCSVFromAPI() {
var response = UrlFetchApp.fetch("xxx");
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dest = ss.getActiveSheet();
SpreadsheetApp.flush();
var req = { pasteData: { data: response.getContentText(), delimiter: ",", coordinate: { sheetId: dest.getSheetId() } } };
Sheets.Spreadsheets.batchUpdate({requests: [req]}, ss.getId());
}
CodePudding user response:
Can you try this code?
const req = [
{range: "TEST", // //put your sheetname here
values: data}
];
//append result to Records Sheet
Sheets.Spreadsheets.Values.batchUpdate({data: req, valueInputOption: "USER_ENTERED"},ss.getId());
CodePudding user response:
function importCSVFromAPI() {
var response = UrlFetchApp.fetch("xxx");
var ss.getSheetByName('TEST');
var dest = ss.getActiveSheet();
SpreadsheetApp.flush();
var req = { pasteData: { data: response.getContentText(), delimiter: ",", coordinate: { sheetId: dest.getSheetId() } } };
Sheets.Spreadsheets.batchUpdate({requests: [req]}, ss.getId());
}