我检查了许多堆栈溢出问题,但无法找到以下问题的答案。如何请求具有使用 Alamofire Swift 获取 api 等参数的 post api?
要求:
http://dev.practice.com/api/v1/test/apply?id=51&social_id=2
身体:
"url": https://www.social.com/some_image_url
我尝试了以下方法,但它不起作用:
let urlString = "http://dev.practice.com/api/v1/test/apply?id=51&social_id=2"
Alamofire.request(urlString, method: .post, parameters: ["url": "https://www.social.com/some_image_url"],encoding: JSONEncoding.httpBody, headers: header).responseJSON {
response in
switch response.result {
case .success:
print(response)
break
case .failure(let error):
print(error)
}
}