Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets &引用;接收到无效的JSON有效负载。”;创建新图纸时_Google Sheets_Google Sheets Api - Fatal编程技术网

Google sheets &引用;接收到无效的JSON有效负载。”;创建新图纸时

Google sheets &引用;接收到无效的JSON有效负载。”;创建新图纸时,google-sheets,google-sheets-api,Google Sheets,Google Sheets Api,我刚开始使用Sheets API,并按照以下设置创建新的工作表: 在此代码中,spreadsheetBody对象为空。为此,我使用了本页上的示例:并将此代码添加到spreadsheetBody变量中: { "range": "Sheet1!A1:D5", "majorDimension": "ROWS", "values": [ ["Item", "Cost", "Stocked", "Ship Date"], ["Wheel", "$20.50", "4", "3/

我刚开始使用Sheets API,并按照以下设置创建新的工作表:

在此代码中,spreadsheetBody对象为空。为此,我使用了本页上的示例:并将此代码添加到spreadsheetBody变量中:

{
  "range": "Sheet1!A1:D5",
  "majorDimension": "ROWS",
  "values": [
    ["Item", "Cost", "Stocked", "Ship Date"],
    ["Wheel", "$20.50", "4", "3/1/2016"],
    ["Door", "$15", "2", "3/15/2016"],
    ["Engine", "$100", "1", "30/20/2016"],
    ["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"]
  ],
}

但是,当我发布此消息时,在“电子表格”处出现错误“接收到无效的JSON有效负载。未知名称“范围”:找不到字段。“”。这里可能有什么问题?

您使用的请求正文是用于

作为示例,创建电子表格的请求主体如下所示。在此示例请求正文中,
[“项目”、“成本”、“库存”、“发货日期”]、[“车轮”、“$20.50”、“4”、“3/1/2016”]
是从您的使用中使用的

请求主体样本: 注:
  • 当此请求正文用于电子表格.create时,将创建一个文件名为
    sampleSpreadsheet
    的电子表格。该表在“A1:D2”处的值为
    [“项目”、“成本”、“库存”、“装运日期”]、[“车轮”、“20.50美元”、“4”、“3/1/2016”]
参考资料:
  • -

发布您的完整代码请注意,Google API Explorer可以让您以交互方式构建和测试相关的资源参数,并检查响应。@Leon我很高兴您的问题得到解决。也谢谢你!
{
  "properties": 
  {
    "title": "sampleSpreadsheet"
  },
  "sheets": 
  [
    {
      "data": 
      [
        {
          "startRow": 0,
          "startColumn": 0,
          "rowData": 
          [
            {
              "values": 
              [
                {
                  "userEnteredValue": 
                  {
                    "stringValue": "Item"
                  }
                },
                {
                  "userEnteredValue": 
                  {
                    "stringValue": "Cost"
                  }
                },
                {
                  "userEnteredValue": 
                  {
                    "stringValue": "Stocked"
                  }
                },
                {
                  "userEnteredValue": 
                  {
                    "stringValue": "Ship Date"
                  }
                }
              ]
            },
            {
              "values": 
              [
                {
                  "userEnteredValue": 
                  {
                    "stringValue": "Wheel"
                  }
                },
                {
                  "userEnteredValue": 
                  {
                    "numberValue": 20.5
                  },
                  "userEnteredFormat": 
                  {
                    "numberFormat": 
                    {
                      "type": "NUMBER",
                      "pattern": "$##.00"
                    }
                  }
                },
                {
                  "userEnteredValue": 
                  {
                    "numberValue": 4
                  }
                },
                {
                  "userEnteredValue": 
                  {
                    "numberValue": 42372
                  },
                  "userEnteredFormat": 
                  {
                    "numberFormat": 
                    {
                      "type": "DATE",
                      "pattern": "d/m/yyyy"
                    }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}