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

Push content of a JSON file as a PR Comment

Srinivas Aluka October 4, 2022

I am trying to post a comment with the content of JSON file(example: cat somefile.json)  as a PR comment via rest API 2.0.


Any help can be appreciated



Srinivas Aluka

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 2, 2022

Hi @Srinivas Aluka,

You will need to pass the content of the file in the data of the request and any new lines should be escaped.

For example, if the content of the JSON file is the following:

"a": "a",
"b": "b"

You can post it as a PR comment via API with a call like the following:

curl -u BitbucketUsername:AppPassword \
-X POST "" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"content":{"raw": "{ \n\"a\": \"a\", \n \"b\": \"b\" \n}"}}'


BitbucketUsername is the username of a Bitbucket account with access to the repo
AppPassword is an app password for the account
workspace-id is the workspace id of the workspace that owns the repo
pr-id is the id of the PR where you want to post the comment

Please feel free to let me know if that works for you and if you have any questions

Kind regards,

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events