Ive been googling and trying for the last few days regarding the automatic escaping of forward slashes of alamofire.
(Where "/path/image.png" becomes "\/path\/image.png")
However all the answers either point towards a solution if your using swiftyJson, sending via a httpBody or using the Alamofire Parameter Class.
https://github.com/SwiftyJSON/SwiftyJSON/issues/440
Im not using SwiftyJson and feel to install the API just to resolve the issue is a case of hitting the nail with a sledge hammer.
Anyway.
My issue is whenever I'm trying to send parameters to an API, Alamofire's JSONEncoding.default kindly escapes forward slashes. I don't want Alamofire to do this.
In my case I want to send the following parameter and have Alamofire ignore the forward slashes
let parameter : Parameters = ["transaction": "/room/120"]
Alamofire.request(endPoint , method: .post, parameters: parameter ,encoding: JSONEncoding.default , headers: header).validate(statusCode: 200..<300).responseObject { (response: DataResponse<SomeModel>) in
}
Maybe creating a custom json encoder is the way to do this but I find very little documentation on how best to go about it.
I have also tried
let parameter : [String : Any] = ["transaction": "/room/120"]
Alamofire.request(endPoint , method: .post, parameters: parameter ,encoding: JSONEncoding.default , headers: header).validate(statusCode: 200..<300).responseObject { (response: DataResponse<SomeModel>) in
Really appreciate all your help and suggestions.
Ive even read that the backend should be able to deal with the escaping characters, but its working fine for the android dev. Thus if its my code that is sending the wrong data, then I feel it should resolved at the source
Thomas