1

I am using Drupal 7, with the Services module. I have the REST API enabled.

I have successfully done a user.login, and have retrieved the session id and session name, and then constructed the Cookie from same. I can successfully get a list of ALL nodes using this:

curl -i -X GET \
  -H Cookie:SESS02cbaaadbeeef=Dw8dsijhd9usdkjlb4Plsz_dipuJumGww \
  -H Accept:application/json \
  http://myserver/rest/node

How do I get the list of nodes of a specific type? Eg, nodes of type=forum ?

I tried

curl -i -X GET \
  -H Cookie:SESS02cbaaadbeeef=Dw8dsijhd9usdkjlb4Plsz_dipuJumGww \
  -H Accept:application/json \
  http://myserver/rest/node?type=forum

But that gave me the same list of all nodes.


Edit. this is what worked for me:

curl -i -X GET \
  -H Cookie:SESS02cbaaadbeeef=Dw8dsijhd9usdkjlb4Plsz_dipuJumGww \
  -H Accept:application/json \
  'http://myserver/rest/node?parameters\[type\]=forum'

Thanks to burnsjeremy.

1 Answer 1

2

Services 3.x

You would use the parameters like this: http://localhost/endpoint/node?parameters[type]=node_type

You can find out more how to use this by looking in the code (going off memory here): File: services/resources/node_resource.inc function: _node_resource_index

1
  • THANK YOU! Worked perfectly. There is a need for more examples in the docs. I will read the code you suggested.
    – Cheeso
    Commented Mar 16, 2015 at 18:32

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.