1
votes

I'm using tastypie for a REST interface in django, from Xcode I can call the server and get data successfully using RestKit however I cannot POST data. I know it's hitting the right area as I had a 401 then turned on authentication() in django and that problem was solved, now I'm receiving a 501 Not Implemented Error. I've also manually added the detail and list_allowed_methods to allow all forms POST/GET/ETC. I've Googled and overflowed to no avail! Help!

Here's the code I'm using for POSTING (I'm new to RestKit so be gentle)

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)];

Screenshot - xcode RestKit Code

Here's the Error See Screenshot 501 Not Implemented Xcode Error

Text from Screenshot

2012-12-19 13:23:26.145 Parkable[36586:4b07] I 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 "Expected status code in (200-299,400-499), got 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=Expected status code in (200-299,400-499), got 501, AFNetworkingOperationFailingURLResponseErrorKey=} 2012-12-19 13:23:26.158 Parkable[36586:4b07] E restkit.network:RKObjectRequestOperation.m:271 Object request failed: Underlying HTTP request operation failed with error: Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299,400-499), got 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=Expected status code in (200-299,400-499), got 501, AFNetworkingOperationFailingURLResponseErrorKey=} 2012-12-19 13:23:26.159 Parkable[36586:c07] failure - Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299,400-499), got 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=Expected status code in (200-299,400-499), got 501, AFNetworkingOperationFailingURLResponseErrorKey=}

1

1 Answers

0
votes

To answer my own question the 501 error went away after adding in the

class UserResource(ModelResource):

to the resources.py file and registering it with urls.py

v1_api.register(UserResource())