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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST API: get file from git repo is packed in lines and text nodes

Edited

I am getting a JSON file with:

GET a file with {Server}/rest/api/1.0/{project}/repos/{reponame}/browse/{filename}?at={version}

The file now has nested nodes which I really wouldnt like to get, so that I dont have to parse them away. Here some lines of the result:

{
  "lines": [
    {
      "text": "{"
    },
    {
      "text": "    \"ModuleName\": \"MyModuleName\","
    },
    {
      "text": "    \"Author\": \"MyAuthorname\","
    },
    {
      "text": "    \"Description\": \"MyDescription\","
    },
    {
      "text": "    \"Type\": \"cmake\","
    },
    {
      "text": "    \"Components\": ["
    },
    {
      "text": "\t\t\"inc\", \"lib\""
    },
    {
      "text": "    ],"
    },

(...)

The raw API (url with .../{repo}/raw/..) call doesnt work for me. I am working with bitbucket v4.10.1.

Is there a native way of retreiving the files raw or is it necessary to parse the files to original state by myself?

Thank you very much!

 

 

 

 

 

 

2 answers

1 accepted

1 vote
Answer accepted

Hello, I found out, that the access works over the non REST paths:

{Server}/{project}/repos/{reponame}/browse/{filename}?raw&at={version}

--> solved

Hi there,

You could use this url to do GET on the file:

{Server}/rest/api/1.0/{project}/repos/{repo}/raw/{file_path}?at={version}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,751 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you