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

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -