Ios 如何使用Alamofire在swift 3中打印http请求的正文

Ios 如何使用Alamofire在swift 3中打印http请求的正文,ios,swift,httprequest,alamofire,Ios,Swift,Httprequest,Alamofire,我正试图在swift 3中使用Alamofire,使用x-www-form-urlencoded主体,发出一个补丁请求,但它不起作用。我想打印请求的正文,以便在邮递员发出请求时与结果进行比较 这是我的密码 let parameters: [String:AnyObject] = ["conversation[emails_attributes][0][content]":text as AnyObject] alamofireManager.request(URL, method: .patc

我正试图在swift 3中使用Alamofire,使用x-www-form-urlencoded主体,发出一个补丁请求,但它不起作用。我想打印请求的正文,以便在邮递员发出请求时与结果进行比较

这是我的密码

let parameters: [String:AnyObject] = ["conversation[emails_attributes][0][content]":text as AnyObject]

alamofireManager.request(URL, method: .patch, parameters: parameters, encoding: URLEncoding(destination: .httpBody), headers: headers)
    .response { httpResponse in
        if let error = httpResponse.error {
            print(error)
            completionHandler(.defaultFailResponse(NSLocalizedString("An errror has occurred",comment:"General Error Title")))
        } else {
            print("HTTP: \(httpResponse.response?.statusCode)")
            if let response = httpResponse.response{
                switch response.statusCode {

                case 200:
                    let jsonData = JSON(data: httpResponse.data!)
                    if (jsonData == nil) {
                        completionHandler(.defaultFailResponse(NSLocalizedString("Error on Data",comment:"Message error when data is null")))
                        return
                    }
                    print("Message Created")
                    completionHandler(.defaultSuccessResponse)
                default:
                    completionHandler(.defaultFailResponse(NSLocalizedString("Connection Error",comment:"Connection failed")))
                }
                print("Failed")
            }
        }
    }
我尝试了
打印(“request body:\(request.HTTPBody)”
但不起作用,错误消息是

错误:对成员“请求”的引用不明确(\ u0:method:parameters:encoding:headers:)'


打印(“请求正文:\(httpResponse.request.HTTPBody)”)
?另外,它可能在(NS)数据中,因此您可能必须转换它。对于您的问题,我认为
let参数:[String:AnyObject]=[“对话[emails\u attributes][0][content]”:文本作为AnyObject]
似乎很奇怪。您的意思是
let parameters=[“conversation”:[“emails_attributes”:[[“content”:yourText]]]]
或类似的东西:您可以使用
let-httpBodyData=JSONSerialization.data(with-jsonobject:customer,options:[])
let-jsonDataString=String(data:httpBodyData!,encoding:String.encoding.utf8)作为字符串进行测试