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

Add comments to Pull Requests from API

n January 13, 2013

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
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2013

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

n January 14, 2013

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?)

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2013

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

Kannan S July 7, 2016

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

Venugopal B V June 20, 2019

Hi Charles,

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

ranjan745597 September 30, 2019

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
aphex3k November 12, 2019

I'm receiving the same error as ranjan

ranjan745597 November 13, 2019

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

Like # people like this
Earl Berg April 6, 2020

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

Sahil Kumar June 25, 2021

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
AUG Leaders

Atlassian Community Events