13

I am able to get raw file content using the Bitbucket REST API, as

https://api.bitbucket.org/1.0/repositories/AccountName/Repo_Slug/raw/master/MyFolder/MyFile.cs,

Is there a equivalent to get it from Stash using Stash Rest API. I couldn't find it here: https://developer.atlassian.com/static/rest/stash/2.0.1/stash-rest.html#resources

TylerH
  • 20,799
  • 66
  • 75
  • 101
parsh
  • 746
  • 1
  • 10
  • 23

2 Answers2

18

Just specify the file's URL and append ?raw

http://example.com/projects/TES/repos/testrepo/browse/testfile?raw

As I mentioned, that is not a function of either REST API, it is just the full URL of the file.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Eddie
  • 9,696
  • 4
  • 45
  • 58
  • 1
    You can get a JSON summary of file details using a URL like http://mydomain.com/rest/api/1.0/projects/TES/repos/testrepo/browse/testfile – Eddie Dec 28 '12 at 01:11
  • 4
    Curious, I don't see any reference to a branch name there. Does it default to `master`? Is there a way to specify a different branch? All assuming it's a git repo, of course. – Trebor Rude Jun 27 '13 at 11:58
  • 4
    To get file from branch `feature` you need to download file from http://example.com/projects/TES/repos/testrepo/browse/testfile?raw&at=feature – bessarabov Sep 16 '14 at 08:22
  • 2
    Is there any way to get, the raw file using JAVA API? What I am looking is to get raw file with SSH Key authentication, which is used from GIT bash. But the SSH authentication, I suppose would not be working with REST API, so I am looking if JAVA API or GIT API could help with that. Please share some inputs or any examples – Chakradhar K Mar 24 '15 at 05:05
2

With 1.0 of stash/bitbucket api, you could use the below to get the raw file content

    https://example.com/rest/api/1.0/TES/repos/testrepo/raw/testfile?at=feature/branch
velsim
  • 553
  • 1
  • 7
  • 17
  • slight correction, `https://example.com/rest/api/1.0/projects/TES/...` Missing `projects`. Ref: https://docs.atlassian.com/bitbucket-server/rest/7.7.1/bitbucket-rest.html#idp358 – Fred.W Mar 18 '22 at 17:11