Json请求使用AlamoFire

时间:2015-05-14 22:35:40

标签: json alamofire

这是我的Json请求

var postsEndpoint = "http://test/Search"

let test = ["SearchCriteria":["ForeName":"jack", "Surname":"jill"]];


    request(.POST, postsEndpoint, parameters: test, encoding: .JSON)
        .responseJSON { (request, response, data, error) in
            if let anError = error
            {
                println("error calling POST on /posts")
                println(error)
            }
            else if let data: AnyObject = data
            {

                let post = JSON(data)
                println("The post is: " + post.description)
            }

我的请求是否存在问题,因为我收到以下错误:

错误调用POST on / posts 可选(错误域= NSCocoaErrorDomain代码= 3840"操作无法完成。(可可错误3840。)"(字符3周围的值无效。)UserInfo = 0x7fdd00414c80 {NSDebugDescription =字符3周围的值无效})

1 个答案:

答案 0 :(得分:0)

迟到了,但我找到了这个帖子。

我遇到了运行Django dev服务器并获得You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data.

的同样问题

postsEndpoint附加一个斜杠,使其变为......
var postsEndpoint = "http://test/Search"