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

borek2 picture borek2  Â·  3Comments

Footjy picture Footjy  Â·  3Comments

sarbogast picture sarbogast  Â·  3Comments

Tulleb picture Tulleb  Â·  3Comments

lvandal picture lvandal  Â·  3Comments