Failing to post comments through the API


#1

We are displaying blog posts in a custom site retrieving the blog posts through the API which works fine.

However we are trying to implement the comment API for posting comments but are getting stuck at the following:

We are sending the following data to: https://api.hubapi.com/comments/v3/comments

userName=Test
userEmail=test%40example.com
userUrl=http%3A%2F%2Fexample.com
comment=Test+comment.
portalId=_REDACTED_ (taken from top right hubspot portal)
contentId=_REDACTED_ (the blog post ID taken from the API)
collectionId=_REDACTED_ (the blog post group ID taken from the API)
contentPermalink=_REDACTED_ (the blog post url)
contentAuthorName=_REDACTED_ (the blog post author name)
contentAuthorEmail=_REDACTED_ (the blog post author email)
hs_context=_REDACTED_ (taken from the hubspot cookie)

But we are getting a 400 HTTP error with the following message:

{
    "status": "error",
    "message": "Unable to deduce portalId from this request.",
    "correlationId": "c2e2f43a-64b8-485d-bfbe-___",
    "requestId": "00dd251f22bed29ad8d392___"
}

Can you guys point us in the right direction? In the documentation is no mention of the portalId parameter so we added it ourselfs to see if that would help but that doesn’t change the error.


#2

Hi @stayallive

Are you making this request using an API key or an access token? If you’re using an access token, is this an OAuth2 token (using the Authorization header) or an old token (using the access_token= query parameter?


#3

Hey @dadams,

We are using an API key (hapikey parameter) in the URL the same way we are retrieving comments.

So the full URL we are posting to is: https://api.hubapi.com/comments/v3/comments?hapikey=___&portalId=___

I just tried to fiddle arround again and now we are getting a 500 response internal error (we had the parameters in the post body for testing).

So something changed… but it’s still not working as expected :slight_smile: