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
  • 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"}]}

Reply
  • 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"}]}

Children
No Data