0
 let parameters : [ String : Any] = [
            "test_id": 1,
            "std_id": 1,
            "d_mins": 10
        ]

       Alamofire.request("http://cloud.com/xxx",method: .post,parameters: parameters,encoding: JSONEncoding.default,headers: headers).responseJSON { response in
            print(response)
            print(response.result)
           print(response.result.isSuccess)
        }

    }

Facing below error

Notifying FAILURE: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value.})) FAILURE false

enter image description here

Badrinath
  • 325
  • 1
  • 7
  • 25
  • 1
    I think if you watch the request with something like [Charles](http://charlesproxy.com) or [Wireshark](http://wireshark.org), I bet you'll see a well-formed JSON request. The problem may well rest in the server code (or some disconnect between what the client is sending and what the server was expecting). Are you sure it's expecting numeric values and not string values? Are you sure your server can handle the JSON request and is not, for example, expecting a `x-www-form-urlencoded` request? Are you sure the keys are right? – Rob Jan 31 '17 at 06:07
  • @MücahitTekin tried no luck :( – Badrinath Jan 31 '17 at 06:09
  • @Rob i tried let body: Parameters = [ "institute_id": 1, "student_id": 1, "delayed_mins": 10 ] , tried the same thing from POSTMAN client it works with json like below {"institute_id":1,"student_id":1,"delayed_mins":10} it works .. – Badrinath Jan 31 '17 at 06:11
  • Maybe this helps http://stackoverflow.com/a/33541493/1877810 – Mücahit Tekin Jan 31 '17 at 06:12
  • What is the `statusCode` of the response? I might add a `validate()` call before the `responseJSON` and make sure you're getting a 200 response code. See [Response Validation](https://github.com/Alamofire/Alamofire#response-validation). – Rob Jan 31 '17 at 06:12
  • tried Alamofire.request("http://cloud.com/xxx",method: .post,parameters: parameters,encoding: JSONEncoding.default,headers: headers) .validate(statusCode: 200..<300) .responseJSON { response in print(response) print(response.result) print(response.result.isSuccess) } No luck – Badrinath Jan 31 '17 at 06:17
  • @Mücahit Tekin u saved my day, changing to responseJson worked .. :) – Badrinath Jan 31 '17 at 06:20
  • @Badrinath great that worked :) – Mücahit Tekin Jan 31 '17 at 06:30
  • Possible duplicate of [Alamofire invalid value around character 0](http://stackoverflow.com/questions/32355850/alamofire-invalid-value-around-character-0) – shallowThought Jan 31 '17 at 07:32

0 Answers0