gpt4 book ai didi

google-sheets - Google Sheet API v4

转载 作者:行者123 更新时间:2023-12-04 23:11:29 32 4
gpt4 key购买 nike

我尝试使用示例“读取多个范围”:

https://sheets.googleapis.com/v4/spreadsheets/{SpreadsheetID}/values:batchGet?ranges=Sheet1!B:B&ranges=Sheet1!D:D&valueRenderOption=UNFORMATTED_VALUES?majorDimension=COLUMNS



来自: Google Sheets API v4 example
我用我的电子表格 ID 替换了“spreadsheetId”。
但是当我发送 GET 请求(通过 postman )时,我收到:
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}

比我用的 https://developers.google.com/oauthplayground/
我用我的电子邮件授权了电子表格 API v4,最后我用 key 生成了一个长链接,并看到了我的数据表内容的正确响应。

我的问题是下一个:
为什么不可能使用来自 Google API 的示例 ( https://developers.google.com/sheets/api/samples/reading ) 仅替换电子表格 ID。
P.s 指向我的电子表格的链接是公开的,我的电子表格是公开的并且以 JSON 格式提供,Google Spreadsheet API v4 的 url 的正确用法是什么,以便通过多个请求发送 batchGet?

P.s.s 我使用另一种方法并且它有效,但为什么第一种方法(v4)不起作用:
https://spreadsheets.google.com/feeds/list/{SpreadsheetID}/od6/public/values?alt=json

当我尝试在一个请求中组合 2 个 API 并收到错误“重复查询参数范围不一致”时:
https://spreadsheets.google.com/feeds/list/{SpreadsheetID}/od6/public/values:batchGet?ranges=Sheet1!B:B&ranges=Sheet1!D:D&valueRenderOption=UNFORMATTED_VALUES?majorDimension=COLUMNS

======================================
已编辑:

电子表格 ID:1KBk1J7TJCwnayMnTbaysqvFk98kDdxXWNw2JYc3bW0

在隐身模式下可用: Spreadsheet

JSON 格式: JSON

引用: Google Sheets API v4: Read multiple ranges

与 SpreadSheetID 相同的示例: ERROR 403

最佳答案

我相信您在 url 中缺少 API。这是来自 google 电子表格 api 文档。

要获取 API key :

在 API 控制台中打开凭据页面。

API keys: A request that does not provide an OAuth 2.0 token must send an API key. The key identifies your project and provides API access, quota, and reports.

The API supports several types of restrictions on API keys. If the API key that you need doesn't already exist, then create an API key in the Console by clicking Create credentials > API key. You can restrict the key before using it in production by clicking Restrict key and selecting one of the Restrictions. To keep your API keys secure, follow the best practices for securely using API keys.

After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.

The API key is safe for embedding in URLs; it doesn't need any encoding.



Google Spreadsheet Docs

关于google-sheets - Google Sheet API v4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44750946/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com