googleapis version: 34.0.0I tried to follow this example to use the batchUpdate API but I'm not able to use the API successfully.
const {google} = require('googleapis');
const sheets = google.sheets('v4');
try {
const options = {
auth: new google.auth.JWT(
'client_email',
null,
'private_key',
['https://www.googleapis.com/auth/spreadsheets']
);
spreadsheetId: 'spreadsheetId',
resource: {
requests: [{
addSheet: {properties: {title: 'title'}}
}]
}
};
await new Promise((resolve, reject) => {
sheets.spreadsheets.values.batchUpdate(options, (err, res) => err ? reject(err) : resolve(res));
});
} catch (error) {
console.error(error);
}
Solved, I was using the wrong API.
sheets.spreadsheets.values.batchUpdate -> sheets.spreadsheets.batchUpdate
Most helpful comment
Solved, I was using the wrong API.
sheets.spreadsheets.values.batchUpdate->sheets.spreadsheets.batchUpdate