Get raw file content using Stash Rest API
Asked Answered
C

2

14

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

Centralize answered 28/12, 2012 at 0:14 Comment(0)
J
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.

Jea answered 28/12, 2012 at 1:1 Comment(4)
You can get a JSON summary of file details using a URL like mydomain.com/rest/api/1.0/projects/TES/repos/testrepo/browse/…Jea
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.Puzzle
To get file from branch feature you need to download file from example.com/projects/TES/repos/testrepo/browse/…Anisotropic
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 examplesDistinct
L
3

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
Lockett answered 11/3, 2021 at 20:19 Comment(1)
slight correction, https://example.com/rest/api/1.0/projects/TES/... Missing projects. Ref: docs.atlassian.com/bitbucket-server/rest/7.7.1/…Koala

© 2022 - 2024 — McMap. All rights reserved.