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,294,209
Community Members
 
Community Events
165
Community Groups

Add comments to Pull Requests from API

How to add comment to Pull Request in Stash REST API? REST API Browser doesn't help.

1 answer

1 accepted

1 vote
Answer accepted

Hi nfx,

Yeah I'm afraid our REST documentation is lacking at the moment. We are looking to update them in an upcoming release.

To add a comment via REST:

http://host:port/rest/api/latest/projects/$PROJECT/repos/$REPO/pull-requests/$PR/comments

curl -X POST -d '{"text":"your comment"}' $URL

Or if you're replying

curl -X POST -d '{"text":"your comment","parent":{"id":1061}}' $URL

I hope this helps,

Charles

Hello Charles,

I've already figured that out. Somehow. But thank you :)

Btw, Rest Api Browser when used with parameters that are already in URL is totally unusable for playing with API. would you fix that someday?)

Hi nfx,

As I said - we are looking to improve the REST documentation this year. The REST browser will updated alongside Stash as new versions are released.

Charles

I tried this but comments not updated in Bitbucket cloud. There is none of the message displayed and no error. 

Used 2.0 api, the GET comments works fine.

-Kannan

Hi Charles,

Can you let me know what is $PR in hyperlink format you have provided

HI All ,

 

Getting the below error when trying to add the commnet to a PR as

 curl -k -u ******:***** -X POST -d '{"content": { "raw": "your comment" }}' https://api.bitbucket.org/2.0/repositories/**/********/pullrequests/1/comments

 

"type": "error", "error": {"fields": {"content": "required key not provided", "{\"content\": { \"raw\": \"your comment\" }}": "extra keys not allowed"}, "message": "Bad request"}

 

Any idea what am i missing here

Like # people like this

I'm receiving the same error as ranjan

aphex3k  my issue is resolved after I added the content-type param to the url , pls try the same

Like # people like this

I had to add `Content-Type: application/json` to headers, not the URL. Maybe either is good enough.

use this for linux:

curl -u user:passwd -H "Content-Type: application/json" -X POST -d '{"text":" message "}' 'https://bitbucket.xxx.com/rest/api/1.0/projects/xxxx/repos/xxxx/pull-requests/<pr number>/comments'


Suggest an answer

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

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,151 views 2 9
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