Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Prevención de GoogleJsonResponseException: la llamada API a sheets.spreadsheets.batchUpdate falló con el error: debe especificar al menos una solicitud

Tengo la siguiente función de hoja de cálculo de Google:

 function deleteRows() { const sheetName = "Sheet"; // Please set the sheet name. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheetByName(sheetName); const sheetId = sheet.getSheetId(); const requests = sheet .getRange(`S1:S${sheet.getLastRow()}`) .createTextFinder("Found") .findAll() .map(r => r.getRow()) .reverse() .map(r => ({deleteDimension:{range:{sheetId:sheetId,startIndex:r - 1,endIndex:r,dimension:"ROWS"}}})); Sheets.Spreadsheets.batchUpdate({requests: requests}, ss.getId()); }

El script elimina las filas duplicadas con la actualización por lotes de API , si hay un texto "Encontrado" dentro de la columna S, sin embargo, a veces no hay filas duplicadas, por lo tanto, me gustaría que la función no devuelva el error:

GoogleJsonResponseException: la llamada API a sheets.spreadsheets.batchUpdate falló con el error: debe especificar al menos una solicitud.

y simplemente continúe con la siguiente función que se ejecuta después de finalizar la función deleteRows anterior.

¿Cómo evitar que se devuelva el error si no hay una solicitud?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En su situación, ¿qué tal la siguiente modificación?

De:

 Sheets.Spreadsheets.batchUpdate({requests: requests}, ss.getId());

A:

 if (requests.length > 0) { Sheets.Spreadsheets.batchUpdate({requests: requests}, ss.getId()); }
  • Con esta modificación, cuando requests tienen los valores, se ejecuta Sheets.Spreadsheets.batchUpdate .
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!