Alamofire: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed

Created on 30 Jan 2017  ·  3Comments  ·  Source: Alamofire/Alamofire

Facing json serilization exception for below code , any help is appreciated.

let headers: HTTPHeaders = [
"Authorization": "XXXXXX",
"Accept": "application/json",
"Content-Type": "application/json"
]

    let body: Parameters = [
        "test_id": 1,
        "stud_id": 1,
        "delayed_mins": 5
    ]

   Alamofire.request("http://cloud.xxx/api/notify",method: .post,parameters: body,encoding: JSONEncoding(options: []),headers: headers).responseJSON { response in

    print(response)
        print(response.result)
       print(response.result.isSuccess)
     }

Any help is really appreciated.

Uploading Screen Shot 2017-01-30 at 7.10.08 PM.png…

Most helpful comment

changing from responseJSON to responseString worked, closing the issue.

All 3 comments

I tried passing string like below

let body: Parameters = [
"test_id": "abc",
"stud_id": "def",
"delayed_mins": "ghi"
]

It works , may be having issue passing integers in json . Any help would really appreciated.

changing from responseJSON to responseString worked, closing the issue.

very helpful, thanks a lot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tib picture tib  ·  3Comments

shivang2902 picture shivang2902  ·  3Comments

filippovdev picture filippovdev  ·  3Comments

dpstart picture dpstart  ·  3Comments

noear picture noear  ·  3Comments