Google Sheets API v4附加请求使用API密钥接收公共提要的HTTP 401响应 [英] Google Sheets API v4 append request receives HTTP 401 response for public feeds using API Key
问题描述
这与在此处回答的有关如何获取电子表格数据的另一个问题极为相似,但我正在尝试将数据添加到电子表格.这是我的示例卷曲请求:
This is extremely similar to another question answered here about how to GET spreadsheet data, but I'm trying to append data to a spreadsheet. Here's my sample curl request:
curl -H "Content-Type: application/json" -X POST -d '{"range":"A1","majorDimension":"ROWS","values":["Frank2"]}' https://sheets.googleapis.com/v4/spreadsheets/{SPREADSHEET_ID}/values/A1:append?valueInputOption=RAW&key={API-KEY}
以下是回复:
{
"error": {
"code": 401,
"message": "The request does not have valid authentication credentials.",
"status": "UNAUTHENTICATED"
}
}
可以仅使用API密钥来完成此操作,还是我做错了什么?该文档表明,可以公开共享电子表格.
Can this be done only using an API Key or am I doing something wrong? The documentation suggests it is possible if the spreadsheet is shared publicly.
推荐答案
写入电子表格的请求需要身份验证凭据.即使电子表格是公开共享的,通过API写入时,写入内容也必须归因于用户.
Requests that write to the spreadsheet require authentication credentials. Even if the spreadsheet is shared publicly, when writing through the API the write must be attributed to a user.
这篇关于Google Sheets API v4附加请求使用API密钥接收公共提要的HTTP 401响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!