将 Smartsheet API 与 Swift 结合使用
Using Smartsheet API with Swift
是否可以像这样使用 Alamofire:
AF.request("https://api.smartsheet.com/2.0/sheets/",method: .get).responseJSON { Data in debugPrint(Data.result) }
在 Swift 中与 Smartsheet 互动 API?
我希望用一个合理的 https 替换当前的 https 能达到我想要的效果。
我想从 API 获取信息。抛出的错误是我没有 API:
的授权
Swift.Result<Any, Alamofire.AFError>.success({ errorCode = 1004; message = "You are not authorized to perform this action."; refId = 1ca40zco0itdd; }).
我只是需要更好地理解端点并阅读有关 Alamofire 的文档。我将我的代码更改为以下内容并且有效!
let headers: HTTPHeaders = [
"Authorization": "Bearer " + api_key_smartsheet,
"Accept": "application/json"
]
AF.request("https://api.smartsheet.com/2.0/sheets/?includeAll=True", method: .get,headers: headers).responseJSON { response in
debugPrint(response)
}'''
是否可以像这样使用 Alamofire:
AF.request("https://api.smartsheet.com/2.0/sheets/",method: .get).responseJSON { Data in debugPrint(Data.result) }
在 Swift 中与 Smartsheet 互动 API?
我希望用一个合理的 https 替换当前的 https 能达到我想要的效果。
我想从 API 获取信息。抛出的错误是我没有 API:
的授权Swift.Result<Any, Alamofire.AFError>.success({ errorCode = 1004; message = "You are not authorized to perform this action."; refId = 1ca40zco0itdd; }).
我只是需要更好地理解端点并阅读有关 Alamofire 的文档。我将我的代码更改为以下内容并且有效!
let headers: HTTPHeaders = [
"Authorization": "Bearer " + api_key_smartsheet,
"Accept": "application/json"
]
AF.request("https://api.smartsheet.com/2.0/sheets/?includeAll=True", method: .get,headers: headers).responseJSON { response in
debugPrint(response)
}'''