From 1346ae6d04bb8e03aad29a121972bf6c689d0232 Mon Sep 17 00:00:00 2001 From: Florina Muntenescu <2998890+florina-muntenescu@users.noreply.github.com> Date: Fri, 31 Aug 2018 11:36:24 +0100 Subject: [PATCH] Adding examples of API calls for posting a comment Example added for posting a comment to a story and a reply to a comment --- 14_Comments.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/14_Comments.md b/14_Comments.md index fc12232..5870e63 100644 --- a/14_Comments.md +++ b/14_Comments.md @@ -25,3 +25,25 @@ DELETE /api/v2/comments/:id - `parent_comment`: {Comment} The comment this comment is attach to. Either this or `story` will be present. - `story`: {Story} The story this comment is attached to. - `user`: {User} The user that left this comment + +### Posting a comment + +Here's how we would post a comment for a story with ID `101` as a user with ID `1` + +``` +curl -X POST \ +-H "Authorization: Bearer " \ +-H "Content-Type: application/vnd.api+json" \ +-d '{"comments":{"comment":{"body": "First story message"},"links":{"story":"101","user":"1"}}}'\ +https://www.designernews.co/api/v2/comments/ +``` + +Here's how we would post a reply for a comment with ID `123` as a user with ID `1` + +``` +curl -X POST \ +-H "Authorization: Bearer " \ +-H "Content-Type: application/vnd.api+json" \ +-d '{"comments":{"comment":{"body": "First message"},"links":{"parent_comment":"123","user":"1"}}}' \ +https://www.designernews.co/api/v2/comments/ +```