TastyPie / RestKit 501未实现

时间:2012-12-19 20:37:01

标签: ios django restkit tastypie

我在django中使用tastypie作为REST接口,来自Xcode我可以调用服务器并使用RestKit成功获取数据但是我无法POST数据。我知道它正在击中正确的区域,因为我有401然后在django中打开authentication()并且问题已解决,现在我收到501 Not Implemented错误。我还手动添加了详细信息和list_allowed_methods以允许所有表单POST / GET / ETC。我用谷歌搜索并溢出无济于事!救命!

这是我用于POSTING的代码(我是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)];

截图 - xcode RestKit Code

这是错误 见截图 501 Not Implemented Xcode Error

屏幕截图中的文字

  

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不是   已实施):错误域= AFNetworkingErrorDomain代码= -1011   “预计状态代码(200-299,400-499),得到501”   的UserInfo = 0x9170260   {AFNetworkingOperationFailingURLRequestErrorKey = HTTP://127.0.0.1:8000 / API / V1 / parkinglot / 22 /格式= 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请求操作失败,错误:错误   Domain = AFNetworkingErrorDomain Code = -1011“预期的状态代码   (200-299,400-499),获得501“UserInfo = 0x9470f10   {AFNetworkingOperationFailingURLRequestErrorKey = HTTP://127.0.0.1:8000 / API / V1 / parkinglot / 22 /格式= 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代码= -1011“预期状态代码   在(200-299,400-499),获得501“UserInfo = 0x9470f10   {AFNetworkingOperationFailingURLRequestErrorKey = HTTP://127.0.0.1:8000 / API / V1 / parkinglot / 22 /格式= JSON>中   NSErrorFailingURLKey = http://127.0.0.1:8000/api/v1/parkinglot/22/?format=json,   NSLocalizedDescription =预期状态代码(200-299,400-499),得到   501,   AFNetworkingOperationFailingURLResponseErrorKey =}

1 个答案:

答案 0 :(得分:0)

为了回答我自己的问题,在添加

后,501错误消失了
class UserResource(ModelResource):

到resources.py文件并使用urls.py注册它

v1_api.register(UserResource())