在我使用 Swift 学习 Google Sheets API 的过程中,我想将单个范围写入电子表格。
查看快速入门 iOS 指南和基本写作示例,我附带了以下代码:
func constructAndSendAQuery() {
let baseUrl = "https://sheets.googleapis.com/v4/spreadsheets"
let spreadsheetId = "1FhbBdEvpcyHsdfgsdft65eDGHre2fLVki5ZolMmZaRs"
let range = "Sales!A31:C31"
let url = baseUrl + "/" + spreadsheetId + "/values/" + range
let params = ["valueInputOption": "RAW"]
let fullUrl = GTLUtilities.URLWithString(url, queryParameters: params)
let body = GTLObject()
body.JSON = ["majorDimension":"ROWS",
"values": ["One", "Two", "Three"]]
service.fetchObjectByInsertingObject(body,
forURL: fullUrl,
delegate: self,
didFinishSelector: #selector(ViewController.processTheResponse(_:finishedWithObject:error:)))
}
不知道我做错了什么,但我收到错误消息:“在此服务器上找不到请求的 URL”。