How to pass parameters to DIOSNode nodeWithIndex #97

Closed
murphlab opened this Issue Aug 28, 2013 · 4 comments

4 participants

@murphlab

I'm using drupal-ios-sdki 2.0.3 and Drupal 7.2.2

I'm trying to pass parameters to [DIOSNode nodeIndexWithPage...] in order to limit the response to nodes of a specific type. Per the Drupal documentation, the URL should look something like this:

http://host/endpoint/node.json?parameters[type]=cabinet_item

I've tried a number of permutations, such as:

[DIOSNode nodeIndexWithPage:@"0"
                     fields:@"nid,title,type"
                 parameters:[NSArray arrayWithObjects:@"type", @"cabinet_item", nil]
                   pageSize:@"20"
                    success:^(AFHTTPRequestOperation *operation, id responseObject)
{
    ...
}
                    failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
    ...;
}];

This however formats parameters like so:

parameters[]=type&parameters[]=cabinet_item

... which is not what Drupal expects. Is there a way to accomplish this?

@spartansystems

I got this to work (finally) by changing the "parameters:" parameter to NSDictionary, and passing in a NSDictionary object with my keys and parameters instead of an NSArray.

For example:

NSDictionary *parameters = [[NSDictionary alloc]initWithObjectsAndKeys:@"1", @"status", @"page", @"type", nil];

[DIOSNode nodeIndexWithPage:@"0" fields:@"nid, title, type, status" parameters:parameters pageSize:@"100" success:^(AFHTTPRequestOperation *operation, id responseObject) {
    //success
    NSLog(@"Response object: %@", [responseObject description]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    //failure
    NSLog(@"Error: %@", [error description]);
}];

You have to change DIOSNode as well to accept NSDictionary instead of NSArray.

@Trexology

Hi I realise drupal-ios-sdki 2.0.6 DIOSnode nodeIndexWithPage is still asking for NSArray instead of NSDictionary.

As @spartansystems had mentioned, changing the datatype to NSDictionary works well. Not sure if this is a bug or we are passing in wrong values to the NSArray.

Hope @kylebrowning could look into it. Thanks.

@kylebrowning

Ill have an update for 2.0.7 in a little bit

@kylebrowning

2.0.7 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment