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

API 2.0 does not recognize master_branch when attempting to set main branch of repository.

    XMLWordPrintable

Details

    Description

      Not sure if this is a bug, or an enhancement because the documentation doesn't explicitly reference this:
      https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D#put

      If you try to use the same Json Object which is used for API 1.0, the output doesn't show any error but the repo's main_branch is not changed.

      Full output:

      #!python
      
      RonCYJ@RonCYJ-HP MINGW64 ~
      $ curl -X PUT -u rchiateam1:<Password> -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/rchiateam1/test -d &#x27;{"main_branch": "master"}&#x27; #TeamID and API Key
        % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
      100  2283  100  2258  100    25    880      9  0:00:02  0:00:02 --:--:--   880{"scm": "git", "website": "", "has_wiki": false, "name": "test", "links": {"watchers": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/watchers"}, "branches": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/refs/branches"}, "tags": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/refs/tags"}, "commits": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/commits"}, "clone": [{"href": "https://rchiateam1@bitbucket.org/rchiateam1/test.git", "name": "https"}, {"href": "ssh://git@bitbucket.org/rchiateam1/test.git", "name": "ssh"}], "self": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test"}, "html": {"href": "https://bitbucket.org/rchiateam1/test"}, "avatar": {"href": "https://bitbucket.org/rchiateam1/test/avatar/32/"}, "hooks": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/hooks"}, "forks": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/forks"}, "downloads": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/downloads"}, "pullrequests": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/pullrequests"}}, "fork_policy": "no_public_forks", "uuid": "{103269e6-0031-4239-9908-22a537f5404a}", "project": {"key": "RCHIAT1", "type": "project", "uuid": "{3cdb7610-ac9f-40cb-8f60-f80024f014aa}", "links": {"self": {"href": "https://api.bitbucket.org/2.0/teams/rchiateam1/projects/RCHIAT1"}, "html": {"href": "https://bitbucket.org/account/user/rchiateam1/projects/RCHIAT1"}, "avatar": {"href": "https://bitbucket.org/account/user/rchiateam1/projects/RCHIAT1/avatar/32"}}, "name": "CSIT"}, "language": "", "created_on": "2016-08-30T12:07:04.831042+00:00", "full_name": "rchiateam1/test", "has_issues": false, "owner": {"username": "rchiateam1", "display_name": "RchiaTeam1", "type": "team", "uuid": "{07b5291f-231f-4fb2-97e7-8424b33e08d4}", "links": {"self": {"href": "https://api.bitbucket.org/2.0/teams/rchiateam1"}, "html": {"href": "https://bitbucket.org/rchiateam1/"}, "avatar": {"href": "https://bitbucket.org/account/rchiateam1/avatar/32/"}}}, "updated_on": "2016-09-14T15:53:45.391368+00:00", "size": 858930, "type": "repository", "is_private": true, "description": ""}
      
      RonCYJ@RonCYJ-HP MINGW64 ~
      $ curl -X PUT -u ronaldchia:<Password> -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/rchiateam1/test -d &#x27;{"main_branch": "master"}&#x27; # Team Admin with App password
        % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
      100  2283  100  2258  100    25    811      8  0:00:03  0:00:02  0:00:01   816{"scm": "git", "website": "", "has_wiki": false, "name": "test", "links": {"watchers": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/watchers"}, "branches": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/refs/branches"}, "tags": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/refs/tags"}, "commits": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/commits"}, "clone": [{"href": "https://ronaldchia@bitbucket.org/rchiateam1/test.git", "name": "https"}, {"href": "ssh://git@bitbucket.org/rchiateam1/test.git", "name": "ssh"}], "self": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test"}, "html": {"href": "https://bitbucket.org/rchiateam1/test"}, "avatar": {"href": "https://bitbucket.org/rchiateam1/test/avatar/32/"}, "hooks": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/hooks"}, "forks": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/forks"}, "downloads": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/downloads"}, "pullrequests": {"href": "https://api.bitbucket.org/2.0/repositories/rchiateam1/test/pullrequests"}}, "fork_policy": "no_public_forks", "uuid": "{103269e6-0031-4239-9908-22a537f5404a}", "project": {"key": "RCHIAT1", "type": "project", "uuid": "{3cdb7610-ac9f-40cb-8f60-f80024f014aa}", "links": {"self": {"href": "https://api.bitbucket.org/2.0/teams/rchiateam1/projects/RCHIAT1"}, "html": {"href": "https://bitbucket.org/account/user/rchiateam1/projects/RCHIAT1"}, "avatar": {"href": "https://bitbucket.org/account/user/rchiateam1/projects/RCHIAT1/avatar/32"}}, "name": "CSIT"}, "language": "", "created_on": "2016-08-30T12:07:04.831042+00:00", "full_name": "rchiateam1/test", "has_issues": false, "owner": {"username": "rchiateam1", "display_name": "RchiaTeam1", "type": "team", "uuid": "{07b5291f-231f-4fb2-97e7-8424b33e08d4}", "links": {"self": {"href": "https://api.bitbucket.org/2.0/teams/rchiateam1"}, "html": {"href": "https://bitbucket.org/rchiateam1/"}, "avatar": {"href": "https://bitbucket.org/account/rchiateam1/avatar/32/"}}}, "updated_on": "2016-09-14T15:54:13.055318+00:00", "size": 858930, "type": "repository", "is_private": true, "description": ""}
      
      RonCYJ@RonCYJ-HP MINGW64 ~
      $ curl -X PUT -u AannSmMbGdcNKZw38r:<Secret> -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/rchiateam1/test -d &#x27;{"main_branch": "master"}&#x27; #OAuth
        % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
      100    25    0     0  100    25      0      9  0:00:02  0:00:02 --:--:--    11
      
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gsackett Gary
              Votes:
              41 Vote for this issue
              Watchers:
              25 Start watching this issue

              Dates

                Created:
                Updated: