The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am trying to migrate code that we wrote against gitlab to stash (3.1), one of these is a rest request to get the content as a file.
https://{my-host}/rest/api/1.0/projects/CLOUD/repos/myrepo/browse/package.json
This return the content as a set of lines:
{ "lines": [ { "text": "{" }, { "text": " \"name\": \"my-project\"," } ], "start": 0, "size": 3, "isLastPage": false }
Is there a way to return the raw contents(text, base64) of the file instead of having text-text lines?
Also i can't tell from the rest api how to create or update just a file.
You may not be able to get the raw contents of the file from the REST API, but it's available if you tack on ?raw
to the full URL of the file. For example, hitting https://{my-host}/projects/CLOUD/repos/myrepo/browse/package.json?raw
should return the raw contents of that file.
Thanks! Spent a lot of time trying to use the REST API to get the raw file, until I read this post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just use 'raw' in place of 'browse' and it should work.
https://{my-host}/rest/api/1.0/projects/CLOUD/repos/myrepo/raw/package.json
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sudeep Yadav the above is downloading package.json. It isnt fetching the content of package.json
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yes. In a groovy script I am trying to get the rawFile package.json in a variable like below:
``` def bitbucketResponse = "https://bitbucket_url/rest/api/1.0/projects/{projects}/repos/{repos}/raw/{path}/package.json".toURL().getText(requestProperties: [Accept: 'application/json', Authorization: \"Basic \${auth}\"])```
so when I tried only "https://bitbucket_url/rest/api/1.0/projects/{projects}/repos/{repos}/raw/{path}/package.json" in web browser it downloaded the package.json.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I saw one of your answers which includes the below url :
{Server}/rest/api/1.0/{project}/repos/{repo}/raw/{file_path}?at={version}
what is version here ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Shikha Priyedarshi - Oh you are trying it from browser.
Yes, that is expected behavior. Try to make this call using the Postman tool or through your groovy script and in that response you should get the correct value.
Note: You will have to use the respective authorization that you use.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes am using this one from groovy : def xyz = https://bitbucket_url/rest/api/1.0/projects/{projects}/repos/{repos}/raw/{path}/package.json".toURL().getText(requestProperties: [Accept: 'application/json', Authorization: \"Basic \${auth}\"])
but it is not returning anything, the same command is getting stored in the variable to .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Shikha Priyedarshi - I don't think this is how you make a call to a url, you are just assigning a value to a variable that is why it doesn't return anything.
Look up how to make call to endpoints in groovy and you will know what to do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.