I am using Drupal 7 as back-end for a mobile application. I am using comments in my application.

Can anyone help me to reply to comment through web-service?


3 Answers 3


This is how I was able to reply to a comment through web-service.

 URL:- example.com/rest/comment
 Method : POST
 nid :6
 pid: 4
 comment_body[und][0][value]: Some text
  • I was doing it using "cid", didn't get my eye on "pid" .. was really helpful though :)
    – shrish
    May 30, 2014 at 12:20

Adding this answer just in-case someone finds it useful.

nid = node id

pid = comment id you want to reply to

POST http://example.com/rest/comment

Content-Type: application/json
  "subject":"Comment submitted via JSON REST",
        "value":"This is a great article."


<?xml version="1.0" encoding="utf-8"?>

I hope you are using Services Module 3.x. So you can have a look at the unit test case file http://cgit.drupalcode.org/services/tree/tests/functional/ServicesResourceCommentTests.test?id=refs/heads;id2=7.x-3.x#l100 There have a look at the method testCommentCreate.

public function testCommentCreate()

This may solve your problem.

  • yes. Iam using the very same module. And Iam able to create comments as well through services. But Iam not able to reply to a comment.
    – Aparna
    May 30, 2014 at 6:37
  • Well, I haven't done that in Services module to reply to a comment but I can see from your previous replies, the replies are becoming as new comment. I think you are missing the 'pid' field here. This is the comment parent id. $comment->pid = 0; // parent comment id, 0 if none May 30, 2014 at 7:14
  • I tried with pid as well. But still new comments are being created.
    – Aparna
    May 30, 2014 at 7:17
  • Then its hard to say. You can post the codes if you want. Also, just to clarify, you used comment_reply function right? api.drupal.org/api/drupal/modules!comment!comment.pages.inc/… May 30, 2014 at 8:30
  • I have not written any code for this. I was able to save the comments through the url : example.com/rest/comment
    – Aparna
    May 30, 2014 at 9:10

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.