您可以制作一个新的
URLRequest并设置
httpBody为您的编码
jsonData。试试这个代码…
func addProduct(product: MainProduct, completionHandler: @escaping ((JSON?, Error?)->Void)) { let enprer = JSonEnprer() let jsonData = try! enprer.enpre(product) let url = "INSERT_URL" var request = URLRequest(url: url) request.httpMethod = HTTPMethod.put.rawValue request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type") request.httpBody = jsonData Alamofire.request(request).responseJSON { response in switch response.result { case .success(let value): print ("finish") let swiftyJson = JSON(value) completionHandler(swiftyJson, nil) case .failure(let error): completionHandler(nil, error) } }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)