我正在尝试从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
将其作为查询参数添加到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