Alamofire invalid value around character 0

前端 未结 11 2008
忘了有多久
忘了有多久 2020-11-29 02:26
Alamofire.request(.GET, \"url\").authenticate(user: \"\", password: \"\").responseJSON() {
    (request, response, json, error) in
    println(error)
    println(jso         


        
11条回答
  •  没有蜡笔的小新
    2020-11-29 02:59

    Maybe it is too late but I solved this problem in another way not mentioned here:

    When you use .responseJSON(), you must set the response header with content-type = application/json, if not, it'll crash even if your body is a valid JSON. So, maybe your response header are empty or using another content-type.

    Make sure your response header is set with content-type = application/json to .responseJSON() in Alamofire work properly.

提交回复
热议问题