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"
}
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 tohttps://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:
@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
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, thanks
I mean, html is never rendered
You need to use markup: https://commonmark.org/help/Example:
It looks like you're new here. Sign in or register to get started.