這是我的JSON請求JSON請求使用AlamoFire
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 可選(錯誤域= NSCocoaErrorDomain Code = 3840「The operation could not be completed。(Cocoa error 3840.)」(字符3周圍的值無效)。UserInfo = 0x7fdd00414c80 {NSDebugDescription =字符3周圍的值無效。})
錯誤說什麼是錯的:響應你」重新獲得是無效的JSON。使用'responseString'來記錄字符串表示,看看有什麼事。 – mattt