Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,324
Community Members
 
Community Events
184
Community Groups

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"

    }

}

4 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

You need to use markup:  https://commonmark.org/help/

Example:

[*BuildFinished* **SOME BUILD**] 186dab06140a into 165d0168b4d3 \n \n[**✓ BUILD SUCCESS**](https://www.somewebsite.com) - Build *#9999* which took *7 min 46 sec* ✕

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

Deleted user Feb 28, 2020

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.

Deleted user Feb 28, 2020

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

Deleted user Feb 29, 2020

"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.

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 08, 2019

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 # people like 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.

Deleted user Feb 28, 2020

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events