5

Is there a way to filter the nodes that come from a SERVICES node Endpoint, by a field or status?

2 Answers 2

19

http://test/api/node?parameters[nid]=1&parameters[status]=1&fields=status,bid,title

As always you can look at the tests.

Below you can see whats possible.

Fetcher

3
  • Awesome, thanks for your answer. It works for one of my scenario, but I have another requirement. I also have to filter based on a field in my Drupal which is a collection of list items. So how do I modify the query parameter such that the string which I am providing to filter should be contained as one of the listing item in the node? To be more clear, I want something in parameter like: "parameters[field_categories] contains 'fiction'". Here a book can be of more than one category, like a 'classic' as well as 'fiction' etc. Thanks for any suggestions. Commented Nov 19, 2012 at 9:28
  • Well I simply tried something like: "parameters[field_categories]=fiction". This gives me a error: Fatal error: Nesting level too deep - recursive dependency? in /..../includes/common.inc on line 7359" Does this mean that it is indeed trying to fetch the 'fiction' category and failing somewhere while it is attempting to? Commented Nov 19, 2012 at 10:17
  • Ok I fixed the above mentioned problem by replacing var_export() call with serialize() call as mentioned in one of the post. Now I am getting this error "Invalid query provided, double check that the fields and parameters you defined are correct and exist. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_categories' in 'where clause'" Maybe this means that we cannot add query parameters for the custom fields created in Drupal? Is it? Commented Nov 19, 2012 at 10:44
0

At least when the resource is provided by Drupal Commerce Services, this appears to be slightly different. I had to go read the source, but the equivalent to the parameter query string parameter for commerce services is filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.