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,368,548
Community Members
 
Community Events
168
Community Groups

How do i get the file content by passing commit version number?

May i get a bitbucket API to copy the file content by passing the commit version number?

1 answer

0 votes
Patrik S Atlassian Team Dec 09, 2021

Hello @Shruthi R ,

Welcome to Atlassian Community!

The Bitbucket API provides the following endpoint to get the contents of a single file, or the contents of a directory at a specified revision (commit) :

GET /2.0/repositories/{workspace}/{repo_slug}/src/{commit}/{path}
  • When path points to a file, this endpoint returns the raw contents.
  • When path points to a directory instead of a file, the response is a paginated list of directory and file objects

That being said, and example request to that endpoint would like like the following :

curl --request GET --user <BitbucketUsername>:<AppPassword> --url https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src/{commit}/{path}

 

For more information about this and other endpoints available on the Bitbucket API, you can refer to the following documentation:

Hope that helps to address your question. Let us know if you need further assistance :)

Best regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events