'Put a CSV file in a specific Sheet by Name
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());
}
							
						Solution 1:[1]
According to the comments from the original poster this was the solution:
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());
}
    					Solution 2:[2]
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());
    					Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | |
| Solution 2 | liquidkat | 
