【发布时间】:2016-10-31 21:28:52
【问题描述】:
我正在尝试通过他们在 Swift 中的 API 获取 Box 上的文件内容。
curl -L https://api.box.com/2.0/files/file_id/content -H "Authorization: Bearer access_token"
返回正确的内容,但是
curl https://api.box.com/2.0/files/file_id/content -H "Authorization: Bearer access_token"
没有。 所以“-L”部分似乎很关键。
目前为止
let headers = [
"grant_type": "client_credentials",
"Authorization": "Bearer \(token)",
"scope": "public"
]
Alamofire.request("https://api.box.com/2.0/files/file_id/content", headers: headers).responseJSON { responseFile in
if let dataFile = responseFile.result.value {
print("JSON: \(dataFile)")
}
}
如何在其中添加“-L”部分?
整体结构应该是正确的,因为我可以通过从 url 中删除“/content”来成功获取文件的元数据。
【问题讨论】: