Alamofire returns a invalid URL
I am forming an URL string for Searching (urlStrForCustSearch) using the following code
and URL_CUSTOMER_SEARCH = "http://pos1domain.mobi/pos/SV_IOS.asmx/IosJasonToDatatbl":
let customerJson = [[
"customer_id":nil,
"tel":1234567,
"email":nil,
"addr":nil,
"history":nil]]
do{
let JSONData = try JSONSerialization.data(withJSONObject: customerJson, options: [])
let JSONText = String(data: JSONData,
encoding: .utf8)!
let urlStrForCustSearch = URL_CUSTOMER_SEARCH+"?jsonText=\(JSONText)&funname=GET_MM_CUSTOMER_DTL_LST"
print(urlStrForCustSearch)
Alamofire.request(urlStrForCustSearch, method: .post, parameters: [:], encoding: URLEncoding.default, headers: [:]).responseString { response in
if response.result.isSuccess {
print("Response is success")
}else{
print("Response Failed")
print("Reason : \(response)")
}
}
}catch{
print("Cannot parse the dictionary")
}
Console prints desired url
RightURL:
http://pos1domain.mobi/pos/SV_IOS.asmx/IosJasonToDatatbl?jsonText=[{"tel":1234567,"email":null,"history":null,"customer_id":null,"addr":null}]&funname=GET_MM_CUSTOMER_DTL_LST
but on passing the urlStrForCustSearch string to Alamofire as parameter, Alamofire return invalid URL
Response Failed
Reason : FAILURE: invalidURL("http://pos1domain.mobi/pos/SV_IOS.asmx/IosJasonToDatatbl?jsonText=[{\"tel\":1234567,\"email\":null,\"history\":null,\"customer_id\":null,\"addr\":null}]&funname=GET_MM_CUSTOMER_DTL_LST")
As we can see that '\' is added inside the url string
Can any one help me in creating the url string with out '\' string
Please let me know if any input needed.