首页 > 解决方案 > 如何在 Alamofire 中发布带有原始正文的请求?

问题描述

我想用 Alamofire 发布这个原始的身体,我该怎么做?

[
    {
        "x": 234,
        "y": 1,
        "z": 10648
    }
]

标签: iosswiftalamofire

解决方案


请试试这个:

let param = ["x": "234", "y": "1", "z": "10648"]
Alamofire.request(requestURL, method: .post, parameters: param as? Parameters, encoding: JSONEncoding.default, headers: nil).responseJSON { (responseJson) in
     print("Response : \(responseJson)")
     if (responseJson.result.isSuccess){
         //Sucess Part

     } else {
          //Fail part
     }
}

推荐阅读