Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alamofire invalid value around character 0

Alamofire.request(.GET, "url").authenticate(user: "", password: "").responseJSON() {
    (request, response, json, error) in
    println(error)
    println(json)

}

This is my request with Alamofire, for a certain request it sometime works, but sometimes i get:

Optional(Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x78e74b80 {NSDebugDescription=Invalid value around character 0.})

I've read that this can be due to invalid JSON, but the response is a static json string that i have validated in JSON validator as valid. It does contain å ä ö characters and some HTML.

Why am i getting this error sometimes?

like image 603
Lord Vermillion Avatar asked Sep 02 '15 14:09

Lord Vermillion


2 Answers

I also faced same issue. I tried responseString instead of responseJSON and it worked. I guess this is a bug in Alamofire with using it with django.

like image 88
Smit Avatar answered Nov 13 '22 20:11

Smit


In my case , my server URL was incorrect. Check your server URL !!

like image 11
Saeed Avatar answered Nov 13 '22 19:11

Saeed