尝试在Python中对Google Sheets工作表排序时出错

2024-10-04 07:29:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Python对大型googlesheets工作簿中的工作表(即single tab)进行排序。但是,我在执行请求时遇到一个错误:

"Invalid JSON payload received. Unknown name "sort_range": Cannot find field."

Python代码段:

SORT_AMEX_PLAT = {
      "sortRange": {
          "sheetId": AMEX_PLAT_SHEET_ID,
          "startRowIndex": 1,
          "endRowIndex": 20000,
          "startColumnIndex": 0,
          "endColumnIndex": 30,
          "sortSpecs": [
              {
                "dimensionIndex": 0,
                "sortOrder": "ASCENDING"
              }
          ]
        }
    }

    sortRequest = sheet.values().batchUpdate(spreadsheetId=SPREADSHEET_ID, body=SORT_AMEX_PLAT)
    sortResponse = sortRequest.execute()

Tags: idjson排序错误sorttabunknownpayload