我正在尝试调试由Alamofire发送到服务器端点的HTTP头和正文。所有的头参数似乎都是正确的,因为我从端点那里得到了确认,但是我在处理服务器时遇到了问题,在参数字段中发送给它的JSON没有被解析。如何找出请求中发送了什么?
let headers: HTTPHeaders = [
"API-Key": apiKey,
"Accept": "application/json",
"Content-Type": "application/json"
]
let data = ["name":"Don Jonhson"]
Alamofire.request(endPointUrl, method: .post, parameters: data,
encoding: URLEncoding.httpBody, headers: headers).responseJSON() {
response in
if let status = response.response?.statusCode {
switch(status){
case 201:
debugPrint(response)
default:
debugPrint(response)
}
}
...