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

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

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,719 views 10 16
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