我在django中使用tastepie作为REST接口,从Xcode我可以调用服务器并使用RestKit成功获取数据,但是我无法发布数据。我知道它击中了正确的区域,因为我有一个 401 然后在 django 中打开authentication()
并且该问题已解决,现在我收到一个501 Not Implemented
错误。我还手动添加了详细信息并list_allowed_methods
允许所有表单 POST/GET/ETC。我用谷歌搜索并溢出无济于事!帮助!
这是我用于发布的代码(我是 RestKit 的新手,所以要温柔)
RKObjectManager *manager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://127.0.0.1:8000/api/v1/"]];
RKObjectMapping *lotRequestMapping = [RKObjectMapping requestMapping];
[lotRequestMapping addAttributeMappingsFromDictionary:@{@"status" : @"parking_availability"}];
RKResponseDescriptor *lotResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:lotRequestMapping
pathPattern:@"parkinglot/:primaryKey/"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
截屏 -
这是错误请参阅屏幕截图
截图中的文字
2012-12-19 13:23:26.145 Parkable[36586:4b07] 我 restkit.network:RKHTTPRequestOperation.m:143 POST ' http://127.0.0.1:8000/api/v1/parkinglot/22/?format=json ' 2012-12-19 13:23:26.158 Parkable [36586:3807] E restkit.network:RKHTTPRequestOperation.m:156 POST ' http://127.0.0.1:8000/api/v1/parkinglot/22/?format= json ' (501 Not Implemented): Error Domain=AFNetworkingErrorDomain Code=-1011 "预期状态码在 (200-299,400-499),得到 501" UserInfo=0x9170260 {AFNetworkingOperationFailingURLRequestErrorKey=http://127.0.0.1:8000/api/ v1/parkinglot/22/?format=json>, NSErrorFailingURLKey= http://127.0.0.1:8000/api/v1/parkinglot/22/?format=json, NSLocalizedDescription=(200-299,400-499) 中的预期状态代码,得到 501,AFNetworkingOperationFailingURLResponseErrorKey=} 2012-12-19 13:23:26.158 Parkable[36586:4b07] E restkit.network:RKObjectRequestOperation.m:271 对象请求失败: 底层 HTTP 请求操作失败并出现错误:Error Domain=AFNetworkingErrorDomain Code=-1011 “预期状态代码在 (200-299,400-499),得到 501” UserInfo=0x9470f10 {AFNetworkingOperationFailingURLRequestErrorKey=http://127.0.0.1:8000/api /v1/parkinglot/22/?format=json>, NSErrorFailingURLKey= http://127.0.0.1:8000/api/v1/parkinglot/22/?format=json, NSLocalizedDescription=(200-299,400-499) 中的预期状态代码,得到 501,AFNetworkingOperationFailingURLResponseErrorKey=} 2012-12-19 13:23:26.159 Parkable[36586:c07] 失败 - 错误域=AFNetworkingErrorDomain Code=-1011 “预期状态(200-299,400-499) 中的代码,得到 501" UserInfo=0x9470f10 {AFNetworkingOperationFailingURLRequestErrorKey=http://127.0.0.1:8000/api/v1/parkinglot/22/?format=json>, NSErrorFailingURLKey= http://127.0 .0.1:8000/api/v1/parkinglot/22/?format=json , NSLocalizedDescription=预期状态码在 (200-299,400-499), 得到 501, AFNetworkingOperationFailingURLResponseErrorKey=}