I am trying to send Dictionary in POST API. For this purpose I am using Alamofire.
Parameter Dictionary is as follows:
var param: Dictionary<String, AnyObject> =
[
"name" : name,
"email" : email,
"mobile_number" : mobile_number,
"body" : body
] as Dictionary<String, AnyObject>
param["listing_ids[]"] = [772121,772136,772129]
Sending request to Server is as follows:
Alamofire.request(.POST,baseUrl+enquiryEndPoint , parameters: params , encoding: .URL, headers: createHeader()).responseJSON { response in
switch response.result {
case .Success:
guard let response = response.result.value as? Dictionary<String, AnyObject> else{return}
completionBlock(response,error: nil)
case .Failure(let error):
completionBlock([:],error: error)
}
}
When Printing parameter dictionary , error is as follows:
["mobile_number": 457823356, "email": s@gmail.com, "body": Hello, I found your property on <country-website>. Please send me additional information about this property.
Thank you, "listing_ids[]": <_TtCs21_SwiftDeferredNSArray 0x1400d6ff0>(
708783,
589915,
722173,
746261,
618410
)
, "name": s]
Value corresponding to key "listing_ids[]" is an array of Int. This is causing problem here.
Something "_TtCs21_SwiftDeferredNSArray" is written over there which is totally unclear to me.
Due to which I am getting blank response.
Please help me .