【问题标题】:How to post a request with raw body in Alamofire? [duplicate]如何在 Alamofire 中发布带有原始正文的请求? [复制]
【发布时间】:2019-06-06 09:08:18
【问题描述】:

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

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

【问题讨论】:

  • “我想...”不是问题而是要求。这是一个问答网站。
  • 除了@Scriptable 备注:你能展示一下你到目前为止所做的尝试吗?

标签: ios swift alamofire


【解决方案1】:

请试试这个:

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
     }
}

【讨论】:

  • 123 不是字符串,它是 Int
猜你喜欢
  • 2018-12-11
  • 2020-01-15
  • 1970-01-01
  • 1970-01-01
  • 2016-02-11
  • 1970-01-01
  • 2015-12-02
  • 2015-10-08
  • 1970-01-01
相关资源
最近更新 更多