3

How to add a comment when UUID and services are enabled The url which we tried is :

http://localhost/api/comment/uuid_of_new_comment (PUT request) with json raw data:

{
    "comment": {
        "uuid":"uuid_of_forum ",
        "subject": "testing"
    },
    "uuid":"uuid_of_new_comment ",
    "type":"comment"
}

I know that it is not correct. But was not able to find a proper documentation for this any where. So trying some random things !!!

It will be highly helpful if some one can suggest where to find proper documentation for uuid with services .

1

First, when creating a comment you must use POST. Here's an example:

POST: ?q=[my_endpoint]/comment.json

{
  "subject":"Testing...",
  "comment_body":{"und":[{"value":"Hello world..."}]},
  "nid":"123"
}

Secondly, from my understanding the uuid will automatically be generated server side, so you should not need to send it up to Drupal. And lastly, you use the PUT http method to update a comment, and in that case you can send along similar JSON, but include the cid value (e.g. 456) and exclude the nid value in the JSON object, and change the URL path to ?q=[my_endpoint]/comment/456.json

{
  "subject":"Updating...",
  "comment_body":{"und":[{"value":"Hello world again..."}]},
  "cid":"456"
}
  • Hi, Thanks for the reply. But when we use uuid with services POST wont work. We have to use PUT. We got it working. The solution is posted below. – ktrev Aug 16 '15 at 12:26
1

We got it working finally:

URL Used : https://localhost/api/comment/0b1dd306-bbcb-410c-b991-319a3ca189c3 METHOD: PUT JSON:

{
    "nid": "2583",
    "name": "dsad",
    "subject": "sda",
    "language": "und",
    "node_type": "comment_node_forum",
    "date": "now",
    "status": 0,
    "is_anonymous": true,
    "op": "edit",
    "comment_body": {
        "und": [
            {
                "value": "jhkjh"
            }
        ]
    },
    "uuid": "0b1dd306-bbcb-410c-b991-319a3ca189c3"
}

And to allow users other than administers to add comment the patch in the following issue has to be applied: https://www.drupal.org/node/2236229

  • If this is the correct answer you can check it as correct, this will help other users ;-) – Adrian Cid Almaguer Oct 12 '17 at 14:10

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.