0

Currently I am using the following Drupal 8 REST method

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

Content-type: application/json

    {
      "entity_id":[{"target_id":123}],
      "entity_type":[{"value":"node"}],
      "comment_type":[{"target_id":"comment"}],
      "field_name":[{"value":"comment"}],
      "subject":[{"value":"Goodbye World"}],
      "comment_body":[
        {"value":"<p>See you later!</p>","format":"basic_html"}
      ]
    }

201 - Created

This I referred from this link https://goo.gl/kXCS8Q The comment is getting created properly but the Comment's Author Details are not been displayed.

Can anyone tell what else I need to send the parameters for Comments?

  • maybe try to specify the user ID: "uid": [ { "target_id": 1 }] – John Rey Tanquinco Oct 31 '17 at 9:17
  • Thanks @JohnReyTanquinco It worked, but now it only gives me only the User ID for first name, last name and User Image what parameters do I need to add? – Kedar Khaire Oct 31 '17 at 11:24
  • Try to add those fields in your view or manage field or whatever way you want(to your case in comment) then do call a GET method, you will see each params you need. – John Rey Tanquinco Nov 1 '17 at 2:25
  • Glad it works. Feel free to accept my answer if it fits you. – John Rey Tanquinco Nov 1 '17 at 7:46
0

Just adding the solution here.

To get or determine a specific REST parameters, add these fields in your view or content manage fields, then try to access it by running the GET method command. It will show up all parameters of the content/node you need.

Then you can use POST method when planning to update or creating node of your need.

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.