Missed Team ’24? Catch up on announcements here.

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

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

Shruthi R December 8, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 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
AUG Leaders

Atlassian Community Events