title: swift error "Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 1."
body: <p>I am having trouble fixing this error message on my Swift Alamofire POST request (to login a user).</p>
  
  <blockquote>
    <p>'3840' "Invalid value around character 1." </p>
  </blockquote>
  
  <p>I have imported Foundation, <strong>Alamofire</strong>, <strong>SwiftyJson</strong>. There are no authorisation restrictions (no Oauth etc). I'm also getting the same error message when I change the Post (eg to another endpoint, with other parameters and values) but keep the rest of the code/format the same. On my drupal7 REST server 'definitions' it lists the endpoint as /rest/user/login and parameters as 'username' and 'password' strings as I've used.</p>
  
  <p>I'd really appreciate any tips and help?</p>
  
  <blockquote>
    <p>error calling REQUEST
    Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 1." UserInfo={NSDebugDescription=Invalid value around character 1.}    </p>
  </blockquote>
  
  <p>This is my code </p>
  
  <pre><code> @IBAction func loginButtonTapped(sender: AnyObject) {
  
      //using Alamofire
  
      let dataEndpoint: String = "https://www.example.com/rest/user/login"
      let newData = ["username":"Mickey", "password":"123"]
      Alamofire.request(.POST, dataEndpoint, parameters: newData, encoding: .JSON)
          .responseJSON { response in
              guard response.result.error == nil else {
                  // got an error in posting the data, need to handle it
                  print("error calling REQUEST")
                  print(response.result.error!)
                  return
              }
  
              guard let value = response.result.value else {
                  print("no result data  when calling request")
                  return
              }
              let data = JSON(value)
              print("The result is: " + data.description)
      }
  
  }
  </code></pre>
  
  <p>Thank you</p>