0

I'm trying to retrieve all Forums on a Drupal 7 site, using the Services module.

I can get a list of all "forum topics" (which I think of as forum entries or forum posts) this way:

curl -i -X GET \
  -H Cookie:SESSedeadbeef=B0ZkiW3-U2x93yJU-jusjw6A-SgeShSNTYEkG \
  -H Accept:application/json \
  'http://myserver.com/rest/node?parameters\[type\]=forum'

How can I get a list of all the Forums? The parent containers for those posts?

Also, where is the documentation on the Services module? I am having trouble finding anything.

0

ok, I got it to work, I think .

Accomplishing the goal requires two steps. First, find the "taxonomy vocabulary" for forums. Then query the tree for that "taxonomy vocabulary".

Step 1:

curl -i -X GET \
 -H Cookie:SESSe6a353351dfbaaadbeef=B0ZkiW3-TNZ34dfe-uywhw3-UIWJJww \
 'http://myserver/rest/taxonomy_vocabulary?parameters\[machine_name\]=forums' 

Result:

[{
  "vid": "1",
  "name": "Forums",
  "machine_name": "forums",
  "description": "Forum navigation vocabulary",
  "hierarchy": "0",
  "module": "forum",
  "weight": "-10",
  "uri": "http://myserver/rest/taxonomy_vocabulary/1"
}]

Step 2: Using that vid, Query the tree (via POST!!)

curl -i -X POST \
 -H Cookie:SESSe6a353351dfbaaadbeef=B0ZkiW3-TNZ34dfe-uywhw3-UIWJJww \
 -H Accept:application/json \
 -H content-type:application/json \
 'http://myserver/rest/taxonomy_vocabulary/getTree' \
 -d '{ "vid" :"1" }'

Result:

[{
  "tid": "1",
  "vid": "1",
  "name": "General discussion",
  "description": "",
  "format": null,
  "weight": "0",
  "uuid": "dbf914e7-42c2-45f6-b77a-e66a0da72310",
  "depth": 0,
  "parents": ["0"]
}, {
  "tid": "4",
  "vid": "1",
  "name": "Security and Privacy Issues",
  "description": "",
  "format": null,
  "weight": "1",
  "uuid": "7496bfd7-2cb8-4f87-a1e4-f45b1956a01e",
  "depth": 0,
  "parents": ["0"]
}, {
  "tid": "5",
  "vid": "1",
  "name": "etc....",
  "description": null,
  "format": null,
  "weight": "2",
  "uuid": "9fde5519-16b2-453d-852b-a8c416189e30",
  "depth": 0,
  "parents": ["0"]
}, ...]

Or, you can do a parameterized GET:

curl -i -X GET \
 -H Cookie:SESSe6a353351dfbaaadbeef=B0ZkiW3-TNZ34dfe-uywhw3-UIWJJww \
 -H Accept:application/json \
 'http://myserver/rest/taxonomy_term?parameters\[vid\]=1'

The same data is returned.

My next challenge will be to retrieve the list of posts for each particular forum.

Editorial comment: I saw this documented NO WHERE. I really don't understand how developers who use Drupal manage to use the Services module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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