ios - 如何在 Alamofire 中发布带有原始正文的请求?
问题描述
我想用 Alamofire 发布这个原始的身体,我该怎么做?
[
{
"x": 234,
"y": 1,
"z": 10648
}
]
解决方案
请试试这个:
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
}
}
推荐阅读
- ios - enableBackgroundDelivery Health-kit iOS15 无法正常工作
- javascript - 为什么输入文件数据为空?
- python - 如果任何陈述为真,则排除
- java - 如何在远程服务器上运行java文件
- google-cloud-platform - 无法在 GKE 集群上创建 kf 命名空间
- python - 如何减少由许多条件语句组成的函数?
- python - 具有“spawn”上下文的多处理无法访问 Linux 中的共享变量
- javascript - 我尝试使用 await fetch 向节点 js 请求 body json 是空的
- latex - 在 \end{document} 源意外的 Pandoc 错误
- android - Flutter 显示:未处理的异常:PlatformException(错误,句柄对象已存在:8,null,java.lang.IllegalArgumentException...)