Vapor 客户端 GET 响应中的空主体
Empty Body in Vapor Client GET Response
我正在尝试连接
Bamboo HR's API,并且我已经设法使用 curl
和 Swift 基金会的 URLRequest
/URLSession
(以及旧的 Express node.js 应用程序)。
但是,当尝试将 Vapor's client 与 .get()
方法结合使用时,我从 BambooHR 获得了成功的 200
响应 - 但响应的 .body
为空.
这是代码片段:
key 和 {myDomain} 是示例中的占位符
let encodedKey = "\(key):x".utf8.base64String
let directoryRootUrl = "https://api.bamboohr.com/api/gateway.php/{myDomain}/v1/employees/directory"
let response = try drop.client.get(
directoryRootURL,
headers: [
"Accept": "application/json",
"Authorization": "Basic \(encodedKey)",
"Host": "api.bamboohr.com"
])
当我执行 print(response)
时,显示的是:
Response
- HTTP/1.0 200 OK
- Headers:
Connection: close
Vary: User-Agent
Server: Apache
Content-Security-Policy: {...}
Date: Mon, 16 Jan 2017 00:26:31 GMT
Content-Type: application/json
X-Content-Type-Options: nosniff
- Body:
我想知道我是否在使用 Vapor 时做错了什么,或者这是一个错误。
赞建议,设置:
drop.client = FoundationClient.self
创建后 Droplet
有效。
我正在尝试连接
Bamboo HR's API,并且我已经设法使用 curl
和 Swift 基金会的 URLRequest
/URLSession
(以及旧的 Express node.js 应用程序)。
但是,当尝试将 Vapor's client 与 .get()
方法结合使用时,我从 BambooHR 获得了成功的 200
响应 - 但响应的 .body
为空.
这是代码片段:
key 和 {myDomain} 是示例中的占位符
let encodedKey = "\(key):x".utf8.base64String
let directoryRootUrl = "https://api.bamboohr.com/api/gateway.php/{myDomain}/v1/employees/directory"
let response = try drop.client.get(
directoryRootURL,
headers: [
"Accept": "application/json",
"Authorization": "Basic \(encodedKey)",
"Host": "api.bamboohr.com"
])
当我执行 print(response)
时,显示的是:
Response
- HTTP/1.0 200 OK
- Headers:
Connection: close
Vary: User-Agent
Server: Apache
Content-Security-Policy: {...}
Date: Mon, 16 Jan 2017 00:26:31 GMT
Content-Type: application/json
X-Content-Type-Options: nosniff
- Body:
我想知道我是否在使用 Vapor 时做错了什么,或者这是一个错误。
赞
drop.client = FoundationClient.self
创建后 Droplet
有效。