Skip to content

Diagnostic reference

Sheets API batchUpdate: Must specify at least one request

Fix GoogleJsonResponseException: API call to sheets.spreadsheets.batchUpdate failed with error: Must specify at least one request in Apps Script.

Updated December 6, 2026

Apps Script error

GoogleJsonResponseException: API call to sheets.spreadsheets.batchUpdate failed with error: Must specify at least one request

What it means

Sheets.Spreadsheets.batchUpdate() rejects an empty requests array with HTTP 400. Scripts hit this when they build requests inside a loop or conditional filter and call batchUpdate() even on runs where zero rows matched.

Related error messages

  • Exception: API call to sheets.spreadsheets.batchUpdate failed with error: Must specify at least one request
  • GoogleJsonResponseException: API call to sheets.spreadsheets.batchUpdate failed with error: Invalid requests[0]: No request set

Before and after

The code before and after the fix.

Problem 2 changed lines
function highlightPendingRows(spreadsheetId, rows) {
  const requests = [];
  for (let i = 0; i < rows.length; i++) {
    if (rows[i][2] === 'Pending') {
      requests.push({
        autoResizeDimensions: {
          dimensions: { sheetId: 0, dimension: 'COLUMNS', startIndex: 0, endIndex: 3 },
        },
      });
    }
  }
  // Fails with HTTP 400 when no row matched 'Pending'.
  Sheets.Spreadsheets.batchUpdate({ requests }, spreadsheetId);
}
Fixed 3 changed lines
function highlightPendingRows(spreadsheetId, rows) {
  const requests = [];
  for (let i = 0; i < rows.length; i++) {
    if (rows[i][2] === 'Pending') {
      requests.push({
        autoResizeDimensions: {
          dimensions: { sheetId: 0, dimension: 'COLUMNS', startIndex: 0, endIndex: 3 },
        },
      });
    }
  }
  if (requests.length > 0) {
    Sheets.Spreadsheets.batchUpdate({ requests }, spreadsheetId);
  }
}

How to fix it

  • Guard the API call with if (requests.length > 0) before calling Sheets.Spreadsheets.batchUpdate().
  • Verify each pushed object uses a valid Sheets API v4 request key (such as updateCells, repeatCell, or autoResizeDimensions) rather than an empty object {}.
  • Confirm you passed { requests } (plural), not { request }.

Things to check

  • The same empty-array rejection applies to Slides.Presentations.batchUpdate() and Docs.Documents.batchUpdate().
  • myFunction flags literal empty requests arrays and unguarded conditionally populated arrays before execution.

In the Apps Script editor

Catch errors like this before clicking Run.

myFunction (published as Error Checker for Google Apps Script on the Chrome Web Store) checks your code while you edit at script.google.com. Diagnostics, autocomplete, and rule-based quick fixes are free without an account, run in your browser, and request no Google Drive, Gmail, or Apps Script project OAuth scopes. Writing Apps Script with an AI coding agent? Connect the Apps Script MCP server to run the same static checks before pasting code.