我想提出一個要求機智Alamofire這樣的: postman request如何發送表單數據體Alamofire
正如你所看到的,我已經叫參數「數據」,它的值是一個JSON,
我該如何使用Alamofire做到這一點?
我試圖與參數,但犯規wotk
Alamofire.request(urlservice, method: .post, parameters: ["data": parameters], encoding: JSONEncoding.default, headers: nil).responseJSON { response in
有什麼建議?
UPDATE 這裏是我的代碼
var arrayProducts = [[String: String]]()
let product: [String: String] = ["qty": self.txtQty.text!, "precio": self.productPrice, "product_id": self.productId]
arrayProducts.append(product)
let parameters = [
"products": arrayProducts,
"address": self.userInfo["userAddress"]!,
"latitude": "6.157738",
"longitude": "-75.6144665",
"id": 1,
"name": self.userInfo["userName"]!,
"cellphone": self.userInfo["userPhone"]!,
"emei": "23456resdfty"
] as [String : Any]
Alamofire.request(urlservice, method: .post, parameters: ["data": parameters], encoding: JSONEncoding.default, headers: nil).responseJSON { response in
發佈您的代碼如何被你和你的陣列 – GIJOW
CHEC設置你的'parameters' k這個答案https://stackoverflow.com/questions/44484772/how-to-post-nested-json-by-swiftyjson-and-alamofire/44500753#44500753 @EdisonMejia –