Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-20796

Consuming the Deployments Environments API 2.0 is giving an invalid next parameter URL

XMLWordPrintable

      Issue Summary

      Currently, if you use the Deployments Environment API 2.0, it gives an invalid URL for the "next" parameter for pagination.

      https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/ {workspace}/{repo_slug}/environments/
      https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/deployments_config/environments/{environment_uuid}/variables

      Apart from that, using the pagelen parameter to the above API is also not working as expected because it always loads everything regardless of the value of the pagelen parameter.

      Steps to Reproduce

      1. Run the CURL command below:
        curl -sL -u bb_username:app_password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/environments/"
        

        Generate an App password for authentication.

      1. Notice the result
        {"page" : 1,
        "values"[...],
        "pagelen" : 13,
        "size" : 13,
        "next" : "https://SOME_INVALID_DOMAIN_HERE/rest/2.0/accounts/SOME_ID/repositories/SOME_ID/environments?page=2&pagelen=10"}
        

      Expected Results

      • The "next" parameter will give the correct API host domain (e.g. https://api.bitbucket.org).
      • If there are no more results there should be no next link
      • The next link should have the correct hostname and path
      • When following the next link, the correct page should be returned
      • If a limit is provided, the number of results returned should not exceed the limit

      Actual Results

      The "next" parameter is showing an invalid API host domain

      "next" : "https://SOME_INVALID_DOMAIN_HERE/rest/2.0/accounts/SOME_ID/repositories/SOME_ID/environments?page=2&pagelen=10"
      

      Workaround

      For now, we can ignore the "next" parameter for this API, since it loads everything in one API call.

      curl -sL -u bb_username:app_password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/environments/"
      

              Unassigned Unassigned
              mcerezo Mark C
              Votes:
              13 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated: