Comments API: Specify parent comment when creating a new comment


#1

I know nested comments (people replying to other people’s comments) are handled by HubSpot using the “parent” field which is returned in the “List Comments” API call. Is it possible to specify this field when creating a new comment using the “Create New Comment” API?

We’re moving our Hubspot blog to our own website, but we’d like to continue creating the content on HubSpot and have HubSpot manage the comments. We’d like to support nested replies, but for that we need to be able to set a comment’s parent when creating a new comment. I can’t find it in the API documentation for “Create New Comment”, but it’s also missing from the “List Comments” documentation, although the information is actually in the response. So I’m hoping the feature is there and that it’s just not documented :).

Thank you,

Jonathan


#2

Hi @jparent

The ID of the parent comment will be in the parentId of any child comments. The parent comment itself won’t have a reference to any child comments.

Can you tell me more about why you’d be creating the comments in HubSpot if you’re working with an external site?


#3

Hi @dadams,

The reason is that we want our marketing/PR people to be able to get an overview of all comments in HubSpot (Comments tab in the blog section) and be able to Approve/Reject and Reply to comments from there, without having to browse to each individual blog post on our website.

I tried the following POST:
https://api.hubapi.com/comments/v3/comments?hapikey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
{
“comment” : “This is a test comment.”,
“contentId”: “1234123412”,
“collectionId”: “1234123412”,
“contentAuthorEmail”: "SampleHubSpotUser@hubspot.com",
“contentAuthor”: “Sample HubSpot User”,
“contentPermalink”: “http://…hs-sites.com/blog/your-blog-post-title-here”,
“userEmail”: "test@test.com",
“userName”: “Johnny Test”,
“parentId”: “4321432143”
}

It successfully creates a comment, but does not set the parentId (parentId = 0 in the response). I tried replacing “parentId” by “parent”, but I get the following error message:

Invalid input JSON on line 9, column 27: Can not instantiate value of type [simple type, class com.hubspot.comments.base.ParentComment$Builder] from String value (‘4321432143’); no single-String constructor/factory method

Looks like this is the right parameter name, I’m guessing I’d have to supply additional information about the parent, but it’s hard to tell what exactly.

Thanks,

Jonathan