我正在尝试从Google Sheet API接收请求,但是我不知道如何在代码中传递API密钥。
local http = require("socket.http")
local body, code, headers, status = http.request("https://sheets.googleapis.com/v4/spreadsheets/1AQK1WHGsavVmhNugAipMsrweB3m25xp01vtzGA8BvwE/values/Global!A1:D5")
print(code, status, body)
现在我收到错误403
答案 0 :(得分:0)
将其作为查询参数添加到URL的末尾,如下所示:
http.request("https://sheets.googleapis.com/v4/spreadsheets/[spreadsheet-id]/values/Global!A1:D5?key=[YOUR_API_KEY]")
对于下一次,您可以通过单击“尝试此API”窗口中的展开图标来查看Sheets API [1]如何发出请求。
[1] https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get