Google Sheets API v4附加请求使用API​​密钥接收公共提要的HTTP 401响应 [英] Google Sheets API v4 append request receives HTTP 401 response for public feeds using API Key

查看:51
本文介绍了Google Sheets API v4附加请求使用API​​密钥接收公共提要的HTTP 401响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与在此处回答的有关如何获取电子表格数据的另一个问题极为相似,但我正在尝试数据添加到电子表格.这是我的示例卷曲请求:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆