2

I'm running Drupal 7 with the Services module and the Flag Service modules installed but I'm having trouble trying to figure out how to Get countall for a particular post ? Can anyone please tell me what URL I should use ?

URL to get all posts : http://webaddess/rest/events

URL to get one Post : http://webaddess/rest/node/3591

1
  • I managed to find URL but getting this error : 406 Not Acceptable : There is no flag with node I am doing POST with this URL : website.com/rest/flag/countall Header : Content-Type: application/json x-csrf-token: token Body : { "flag_name":"content_favorite", "content_id":"3591" }
    – Malik Mati
    Sep 17, 2015 at 15:44

1 Answer 1

1

I had to implement this for DrupalGap/jDrupal:

https://github.com/dontmcyn/flag/blob/master/flag.js#L282

Essentially you make a POST to ?q=rest/flag/countall.json and send along the following data:

var data = {
  flag_name: 'my_flag_name',
  entity_id: 123
}

You may have to JSON.stringify(data) before sending it. And you are right, pass along an X-CSRF-Token header in the POST call, the value of the token can be retrieved here: ?q=services/session/token

4
  • not sure how to use JSON.stringify(data) ? If you can explain it I will really appreciate it ?
    – Malik Mati
    Sep 18, 2015 at 10:47
  • lmgtfy.com/?q=JSON.stringify ;) Sep 18, 2015 at 14:10
  • Thanks :) But I did that before asking you. Actually I am very beginner
    – Malik Mati
    Sep 18, 2015 at 19:25
  • It all depends on what "type" of JavaScript you are doing to make the call (XMLHttpRequest, jQuery.ajax, etc). But in most cases you just do var data = JSON.stringify({ flag_name: 'my_flag_name', entity_id: 123 }); Sep 20, 2015 at 1:54

Your Answer

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

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