I'm using Restkit to communicate with Drupal CMS. When I'm sending the first request everything works fine: I'm getting the correct JSON- string -> awesome. This is what the console says:
2011-06-24 23:00:48.344 MyApp[1399:207] Sending POST request to URL http://mysite.com/myproject/services/rest/service_views/get.json. HTTP Body: view_name=viewsname
If the app tries to send the same request again, nothing happens. None of the delegate-methods get called. The console says:
2011-06-24 23:03:40.224 MyApp[1399:207] Sending GET request to URL http://www.mysite.com/myproject/services/rest/service_views/get.json. HTTP Body:
I'm doing all the Restkit stuff in a special-class (singleton), which I keep as an instance variable of my view-controller. In the init-function of this class I am doing this:
RKObjectManager* objectManager = [RKObjectManager
objectManagerWithBaseURL:kBaseURLKey];
In my view-controller I'm calling a - (void)pollForNewData
function,
which does the following:
RKObjectLoader* objectLoader = [[RKObjectManager sharedManager] loadObjectsAtResourcePath: kRessourceKey objectClass:[RKNotification class] delegate:self];
objectLoader.method = RKRequestMethodPOST;
objectLoader.params = [NSDictionary dictionaryWithKeysAndObjects: @"view_name", @"viewsname", nil];
[objectLoader send];
Can anybody help me? Do I have to do something special after the first response came? Is it possible to cancel a request (if the current view was left)?
Current RestKit source (~0.9.2+) doesn't seem to have loadObjectsAtResourcePath:objectClass:delegate: method.
You could use something like this:
// It's for logging in Drupal's user resource with RestKit.
// You can change the user bits to your need.
RKObjectManager *objectManager = [RKObjectManager sharedManager];
RKObjectMapping *currentUserMapping = [objectManager.mappingProvider objectMappingForKeyPath:@"currentUser"];
RKObjectLoader *objectLoader = [objectManager objectLoaderWithResourcePath:@"user/login" delegate:self];
objectLoader.method = RKRequestMethodPOST;
objectLoader.objectMapping = currentUserMapping;
objectLoader.params = [NSDictionary dictionaryWithObjectsAndKeys:
@"testuser", @"username",
@"testpass", @"password",
nil];
[objectLoader send];
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With