从AFNetworking(iOS)获取404 PATCH请求,但从浏览器获取200

时间:2015-02-20 19:40:53

标签: ios objective-c swift afnetworking-2

我试图向服务器发送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)

                            })

1 个答案:

答案 0 :(得分:0)

代替:

httpRequestOperationManager.PATCH(...)

尝试使用:

httpRequestOperationManager.GET(...)