In my app I need to send Boolean values inside alamofire params. Here is the code
var SearchParams = [String:Any]()
SearchParams["id"] = "125"
SearchParams["my_case"] = false
But in server end boolean value received as String. I have tried in multiple ways like
var SearchParams: [String:Anyobject]?
SrearchParams = ["id":"125","my_case": false]
var SearchParams = [String:AnyObject]()
SearchParams["id"] = "125" as AnyObject
SearchParams["my_case"] = false as AnyObject
But It Wont Works.
Code Here:
var SearchParams = [String:Any]()
SearchParams["id"] = "\(self.SelectedId)"
SearchParams["my_case"] = false as Bool
let fileUrl = Foundation.URL(string: baseurl)
var request = URLRequest(url: fileUrl!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.allHTTPHeaderFields = ["FirmUserId": "\(self.FirmUserId)", "Authorization": "Token token=\(self.AuthToken)","UserId":"\(self.UserId)"]
request.httpBody = try! JSONSerialization.data(withJSONObject: SearchParams, options: .prettyPrinted)
Alamofire.request(request).responseJSON { response in
}