我试图向服务器发送PATCH请求,但我的请愿书总是得到404,但是在浏览器中我得到200。 据我所知,AFNetworking的PATCH请求没有将我的参数附加到URL并导致错误。知道为什么吗?有什么东西我错过了吗? 以下是请愿书:
let params = ["token": token, "id": id]
let requestSerializer = AFJSONRequestSerializer()
let responseSerializer = AFJSONResponseSerializer(readingOptions:
NSJSONReadingOptions.AllowFragments)
let baseURL = NSURL(string: GlobalConstants.WebServiceURL.base)
let httpRequestOperationManager = AFHTTPRequestOperationManager(baseURL: baseURL)
requestSerializer.setValue("application/json", forHTTPHeaderField: "Content-Type")
requestSerializer.timeoutInterval = NSTimeInterval(GlobalConstants.httpRequestTimeout)
httpRequestOperationManager!.requestSerializer = requestSerializer
httpRequestOperationManager!.responseSerializer = responseSerializer
httpRequestOperationManager.PATCH(url,
parameters: params,
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
onSuccess()
}, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in
onFailure(error)
})
答案 0 :(得分:0)
代替:
httpRequestOperationManager.PATCH(...)
尝试使用:
httpRequestOperationManager.GET(...)