Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,084
Community Members
 
Community Events
168
Community Groups

Getting Something went wrong Error while fetching files in a directory

Hey!!

I am trying to fetch all the files from my directory. The curl which I am using is

```
curl -u "deepakpatankar:xxxx" -X 'GET' 'https://api.bitbucket.org/2.0/repositories/deepakpatankar/git-sync-test/src/master/bitbucket?page=1&pagelen=10'
```

But this request fails with the error
```

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="utf-8">

  <title>Something went wrong &mdash; Bitbucket</title>

  <link rel="stylesheet" href="https://d301sr5gafysq2.cloudfront.net/dfb18959be9c/css/entry/bare-aui-8.css">

</head>

<body class="adg3 error-layout-bare ">

<div id="page" data-error-page>

  <div class="adg3-navigation-bare">

    <div class="adg3-navigation-bare--item">

      <a href="/" class="adg3-navigation-bare--link">

        <div class="adg3-navigation-bare--logo"></div>

      </a>

    </div>

  </div>

  <div id="wrapper">

    <div id="content" role="main">

      <div class="aui-page-panel aui-page-panel-no-header">

        <div class="aui-page-panel-inner">

          <div id="error" class="500 aui-page-panel-content">

            <span class="icon icon-500"></span>

            <h1>

              

                Something went wrong

              

            </h1>

            <p>

              While we check things on our end, try refreshing the page. If reloading the page doesn’t help, check our

                <a class="support-ga"

                  data-support-gaq-page="SiteStatus"

                  href="https://status.bitbucket.org/">status page</a>

              for known incidents or planned maintenance.

            </p>

            

              <p class="status">

                If you are still experiencing issues, our support team can be reached via StatusPage.

                Use the code below when reporting your issue, this will help the team look up details of what went wrong:

              </p>

               <p><code>70b9c705fd214998bfd16d53c09915ba</code></p>

            

          </div>

        </div>

      </div>

    </div>

  </div>

</div>

 

<script nonce="">

  // Google Analytics tracking (BB account & BB marketing profile)

  window.ga = window.ga || function () {

    (window.ga.q = window.ga.q || []).push(arguments);

  };

  window.ga.l = +new Date();

  window.ga('create', 'UA-76642781-3', 'auto', 'atl');

  window.ga('atl.send', 'pageview', '/errors/500django');

  window.ga('atl.set', 'referrer', document.URL);

 

  document.querySelectorAll('.support-ga').forEach(link => {

    link.addEventListener('click', () => {

      window.ga('atl.send', 'pageview', '/support/' + link.dataset.supportGaqPage);

    });

  });

</script>

<script async src="https://www.google-analytics.com/analytics.js" nonce=""></script>

</body>

</html>


```



I read the documentation at https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get and the above curl looks correct to me. Can you please have a look and suggest why the API failed.

PS:
I tried the API to get the content of a file and it worked. The curl of that API is very similar to the one having the issue

```
curl -u "deepakpatankar:xxxx" -X 'GET' 'https://api.bitbucket.org/2.0/repositories/deepakpatankar/git-sync-test/src/master/bitbucket/test?page=1&pagelen=10'
```



Screenshot 2021-12-30 at 4.09.49 PM.pngScreenshot 2021-12-30 at 4.09.57 PM.png

2 answers

1 accepted

0 votes
Answer accepted

Hi @Deepak Patankar,

I believe that the reason for this error is the parameter page=1 in the URI. If you remove that, the call should succeed.

I am quoting from our documentation below:

Pagination is often page-bound, with a query parameter page indicating which page is to be returned.

However, clients are not expected to construct URLs themselves by manipulating the page number query parameter. Instead, the response contains a link to the next page. This link should be treated as an opaque location that is not to be constructed by clients or even assumed to be predictable. The only contract around the next link is that it will return the next chunk of results.

[...]

It is important to realize that Bitbucket support both list-based pagination and iterator-based pagination. List-based pagination assumes that the collection is a discrete, immutable, consistently ordered, finite array of objects with a fixed size. Clients navigate a list-based collection by requesting offset-based chunks. In Bitbucket Cloud, list-based responses include the optional size, page, and previous element. The the next and previous links typically resemble something like /foo/bar?page=4.

However, not all result sets can be treated as immutable and finite – much like how programming languages tend to distinguish between lists and arrays on one hand and iterators or stream on the other. Where an list-based pagination offers random access into any point in a collection, iterator-based pagination can only navigate forward one element at a time. In Bitbucket such iterator-based pagination contains the next link and pagelen elements, but not necessarily anything else. In these cases, the next link's value often contains an unpredictable hash instead of an explicit page number. The commits resource uses iterator-based pagination.

Kind regards,
Theodora

Theodora Boudale

Hey!!

Thanks for the answer and explanation!!. Can we specify the pagelen in the request?

I was reading the documentation here 


https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get 

It hasn't listed pagelen as a parameter, so do we have a way to control how many files we want to read ?

Hi @Deepak Patankar

Yes, it is possible to specify pagelen.

If you do, then the next field would also include the same pagelen you specified.

You are very welcome, and if you have any other questions, please feel free to let me know!

Kind regards,
Theodora

Theodora Boudale Can I specify the `pagelen` as 1000? Or it can have a maximum value of 100 only?

Ref: https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events