Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to post html comments on pull request via 2.0 api?

I'm trying to post comments via bitbucket 2.0 api.

Where the doc can be found here:

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/comments#post

 

However, I get  "content.html": "extra keys not allowed" when I create a json where 

content looks like:

{

     "content“:{

          "raw": "blablablabla",

          "html": "blablablabla"

    }

}

3 answers

@stephen  @Steph @Stephen Siferscould you kindly update us if the html content option really works. Otherwise I could switch to Jira or any other options because this is a big necessity for me. Thanks much @Tim Clipsham

0 votes

Hello Chen and welcome to the Community!

When using the REST API to create a comment within a pull request you must ensure your HTML comment is rendered as HTML. Meaning you must ensure that the comment itself is structured using HTML. An example of a test comment would look as follows:

"content": {"raw": "This is a test comment for HTML testing.", "markup": "markdown", "html": "<p>This is a test comment for HTML testing.</p>", "type": "rendered"}

Notice here that the HTML is not plain text and is rendered as HTML itself.

I hope this proves helpful and you’re able to POST your comments to your pull request soon!

Regards,
Stephen Sifers

Hey Stephen, the example seems not working, it stills shows

{
"type": "error",
"error": {
"fields": {
"content.html": "extra keys not allowed",
"content.markup": "extra keys not allowed",
"content.type": "extra keys not allowed"
},
"message": "Bad request"
}
}

your example gives..

 

{"type": "error", "error": {"fields": {"content.html": "extra keys not allowed", "content.markup": "extra keys not allowed", "content.type": "extra keys not allowed"}, "message": "Bad request"}}

 

Can you please post an example that works?

@Stephen Sifers 

I am seeing the same issue as the posters above, and never saw a response.

I am posting the following JSON to

https://api.bitbucket.org/2.0/repositories/<username>/<slug>/pullrequests/<pull_request_id>/comments


:

{
"content": {
"raw": "This is a test comment for HTML testing.",
"markup": "markdown",
"html": "<p>This is a test comment for HTML testing.</p>",
"type": "rendered"
}
}

 

And receiving the following 400 Response:

{
"type": "error",
"error": {
"fields": {
"content.html": "extra keys not allowed",
"content.markup": "extra keys not allowed",
"content.type": "extra keys not allowed"
},
"message": "Bad request"
}
}

I have the same issue, so the endpoint rules doesn't represent what the doc says. 

Like aphex3k likes this

Same for me.

I am facing the same issue.

The json i am sending as payload is:-

{
"content": {
"raw": "Just checking",
"markup": "markdown",
"html": "<p>Just checking</p>",
"type": "rendered"
}
}

I am getting the below output:-

{    "type""error",    "error": {        "fields": {            "content.html""extra keys not allowed",            "content.markup""extra keys not allowed",            "content.type""extra keys not allowed"        },        "message""Bad request"    }}

the provided solution never worked and no response was provided to the comments

Any news for html comments?

+1 here. Any update on this issue? Seems the API is broken for quite some time.

Try sending only the raw value. Apparently that's how Bitbucket does it on their interface.

 

image.png

Do you mind sending the full request to see the other values of your request?

In particular, what do you put for `markup` and `type` attributes?

Seem to not work for me, I am actually thinking of migration to GitHub.

The only allowed value to send to Bitbucket API is `content.raw`. 

I've tested this 2 minutes ago and it works like charm. Of course your content needs to be formatted as markdown.

for my case, it works too for the raw and the comment is saved ok. My problem is with html content. How do you do it, because the structure given by the documentation doesn't work. Tried something like

"content": {
     "raw": "Just checking",
     "markup": "markdown",
    "html": "<h4>Just checking</h4>",
    "type": "rendered"
}

As it is on the documentation, but doesn't work. This is very important for my case.

The result for my case is as shown in screenshot below, thanksScreenshot from 2020-02-28 18-55-27.png

I mean, html is never rendered

same here - this is still not working.

AFAIK it only works with raw data (i.e. markdown). The HTML is rendered on bitbucket side.

How the raw data should be sent here then?

I sent a query as follow and got an error "extra keys not allowed".

The API error message does not provide any meaningful error and the documentation does not help in any way. Which is why so many people are asking here.

 

Thanks.

 

"content": {
     "raw": "# Comment",
     "markup": "markdown"
}

"content": {
     "raw": "# Comment"
}

Like that ;).

Yes, the extra key "markup" is not allowed to be sent to the API endpoint. Thus it needs to be omitted. 

ok so the server infers the content type then.

I am wondering how this is possible to have a lack of documentation on this?

Thanks a lot for your answer.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

487 views 5 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you