ios - Login with Alamofire post method -
i trying login code:
let loginrequest = [ "username" : self.txtusername.text! string, "password" : self.txtpassword.text! string ] let serverurl = serverpath.path + "/test/login" alamofire.request(.post, serverurl, parameters: loginrequest,encoding: .json).responsejson { response in switch response.result { case .success(let data): ... ... case .failure(let error): print("request failed error: \(error)") }
always getting error
request failed error: error domain=nscocoaerrordomain code=3840 "invalid value around character 0." userinfo={nsdebugdescription=invalid value around character 0.}
but i'm trying static operation completed success
let loginrequest = [ "username" : "test", "password" : "123" ]
running code works fine. error comes responsejson
means content being sent server not proper json.
Comments
Post a Comment