How to get blog post comments with nested comments/replies?

I'm using this code but only getting comments that don't have "ParentCommentId"

var host = new ClientCredentialsRestHost("admin", ""http://communitydemo.local.com/", _clientId, _clientSecret);

var response = host.GetToDynamic(2, "comments.json", false, new RestGetOptions
{
     PathParameters = new System.Collections.Specialized.NameValueCollection { { "ContentId", contentId }, { "IncludeChildren", "true" } }
});



community url updated
[edited by: Navneet Singh at 1:21 PM (GMT 0) on Wed, Nov 20 2019]
Parents Reply Children
  • Hi, I tried the following but still not able to get nested comments/replies. Here are the findings. 

    var response1 = host.GetToDynamic(2, "comments/threaded.json", false, new RestGetOptions
    {
        QueryStringParameters = new System.Collections.Specialized.NameValueCollection { { "CommentId", comment.CommentId } }
    });

    API Response :

    {"":null,"Errors":[{"Errors":"Error: '{0}'"},{"Errors":"Required parameter(s) must be provided: ContentUrl, ContentId, ContentTypeId"}]}

    -------------------------------------------------------------------------------------------------------------------------------------------------------


    var response2 = host.GetToDynamic(2, "comments/threaded.json", false, new RestGetOptions
    {
        QueryStringParameters = new System.Collections.Specialized.NameValueCollection { { "ContentUrl", comment.Content.Url }, { "ContentId", comment.Content.ContentId }, { "ContentTypeId", comment.Content.ContentTypeId } }
    });

    API Response:

    {"ThreadedComments":[],"Errors":null}

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    var response3 = host.GetToDynamic(2, "comments/{commentid}/threaded.json", false, new RestGetOptions
    {
        PathParameters = new System.Collections.Specialized.NameValueCollection { { "commentid", comment.CommentId } }
    });

    API Response:

    {"":null,"Errors":[{"Errors":"Error: '{0}'"},{"Errors":"Required parameter(s) must be provided: ContentUrl, ContentId, ContentTypeId"}]}

  • threaded comments endpoints

    Not getting expected API response with different ways I've given above. Am I doing any mistake here in implementing "Threaded Comments Endpoints" API?

  • I have tested both options and they appear to be working fine.

    The Comments endpoint with IncludeChildren = true returns all the comments, not just those with no ParentCommentId.

    {Url}/api.ashx/v2/comments.json?ContentId={ContentId}&IncludeChildren=true

    The Threaded Comment endpoint with the ContentId and ContentTypeId specified returns the same set of comments, but in a threaded format.

    {Url}/api.ashx/v2/comments/threaded.json?ContentId={ContentId}&ContentTypeId={ContentTypeId}