我尝试使用浏览器中的java脚本在新的工作表中插入并命名新的工作表。
在Google's OAuth Playground中使用Spreadsheets V3 API尝试插入工作表(VIA"插入工作表"操作)时,我收到错误415:" Content-Type application / json不是有效的输入类型。"
我尝试使用Google在下拉列表中提供的所有默认内容类型,但都会导致上述错误。除了OAuth游乐场中的内容之外,我还无法找到Spreadsheets V3 API的文档。
是否有人知道正确的内容类型/如何使用java脚本浏览器代码将工作表插入Google表格?
谢谢!
概要/解决方案:
Google表格API v4 是OAuth游乐场中 Spreadsheets v3 的下一个版本。
Google Sheets API v4的参考部分似乎缺少很多API详细信息,但您可以在Google Sheets API v4 migration guide中找到它们。
答案 0 :(得分:1)
您可以使用v4,migration documentation可以帮助您将v3转换为v4。我尝试在OAuth 2.0中使用v4:
POST /v4/spreadsheets HTTP/1.1
Host: sheets.googleapis.com
Gdata-version: 3.0
Content-length: 61
Content-type: application/json
Authorization: Bearer ACCESS_TOKEN
{
"properties": {
"title": "Test Sheets (local)2"
}
}
希望这有帮助。