Quick error "Domain = NSCocoaErrorDomain Code = 3840" Invalid value around character 1. "

I had a problem fixing this error message on my Swift Alamofire POST request (for user login).

'3840' "Invalid value around character 1."

I imported Foundation, Alamofire , SwiftyJson . No authorization restrictions (no Oauth, etc.). I also get the same error message when I change the message (for example, to another endpoint, with different parameters and values), but save the rest of the code / format the same way. In my definition of drupal7 REST "definition", it lists the endpoint as / rest / user / login and the parameters as the strings "username" and "password" as I used.

I would really appreciate advice and help?

call error REQUEST Error Domain = NSCocoaErrorDomain Code = 3840 "Invalid value around character 1." UserInfo = {NSDebugDescription = Invalid value around character 1.}

This is my 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)
    }

}

thank

+4
4

, , JSON (, html). , ( , , json), json- html. , .

, !

Ps: , URL ?; -)

+2

, django . tcp wirehark, :

'ImportError': < type 'exceptions.ImportError' > ,

+1

, "3840 1" 404

Alamofire .

:

0
source

All Articles