I am using the JSON API module and I would like to create a comment. I was able to create nodes based on the documentation found here, but I can't figure out how to create comments.

How can I add a comment using that module? I managed to do it through the default REST API module.


It follows the same pattern in the POST request with relationships section of the docs you linked to.

  • Your endpoint will be /jsonapi/comment/$MY_COMMENT_TYPE.
  • Your data payload will need to contain both the data property (the comment's properties) and relationships property (which will contain the comment's author & the entity reference commented on). To get a more concrete example of your data payload, perform a GET /jsonapi/comment/$MY_COMMENT_TYPE to see examples of existing comments.
| improve this answer | |

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.