Issue #6400 resolved

Internal server error when creating a repository anonymously (BB-7566)

Anonymous created an issue

Hi,

I'm not able to create a new repository using the provided api. I'm always receiving an internal server error. Unencrypted my request locks like the following:

I don't see where the problem is. For example requesting my already created repositories just works fine.

Appreciate your help.

Comments (8)

  1. Brian Nguyen

    Hi,

    We have had some issue with our background tasks over the last few days that may be causing issues with repo creation. We are actively fixing the problem so are you still seeing this issue?

    If so, could you copy and paste the response? It usually includes a reference to what the error is. It would help us track down what is going wrong.

    Cheers, Brian

  2. Anonymous

    Hi,

    yes the issue still exists. In the response I'm getting the following code:

    ad4e1939923b404f993f12b978230839$8bf6c828894a4b0aa6c8cd0596eccc34
    
  3. Brian Nguyen

    Hi,

    Thanks for that. Looking up the key, that error occurs when trying to create a repository as an anonymous user. In order to use that endpoint, you will need to provide your user credentials.

    https://confluence.atlassian.com/display/BITBUCKET/Using+the+Bitbucket+REST+APIs#UsingtheBitbucketRESTAPIs-Authentication

    That said the error message should be much clearer and send a 401 response so I have updated the title and added this issue to our backlog.

    Cheers, Brian

  4. Anonymous

    Hi,

    the thing is I'm not trying to do this as an anonymous user. As I mentioned before requesting my already created repositories works just fine (using the same authentication).

  5. Brian Nguyen

    Hi,

    Would you be able to show me how you are using that endpoint? I have tried reproducing the problem with curl and it is working fine on my end:

    $ curl -X POST --user <username>:<password> https://bitbucket.org/\!api/1.0/repositories/ --data "name=test&scm=git&is_private=true"
    {
        "scm": "git",
        "has_wiki": false,
        "last_updated": "2013-02-20 00:30:18",
        "creator": null,
        "forks_count": 0,
        "created_on": "2013-02-20 00:30:18",
        "owner": "<username>",
        "logo": "https://d3oaxc4q5k2d6q.cloudfront.net/m/c9204e16bf82/img/language-avatars/default_16.png",
        "email_mailinglist": "",
        "is_mq": false,
        "size": 0,
        "read_only": false,
        "fork_of": null,
        "mq_of": null,
        "followers_count": 1,
        "state": "creating",
        "utc_created_on": "2013-02-19 23:30:18+00:00",
        "website": "",
        "description": "",
        "has_issues": false,
        "is_fork": false,
        "slug": "something",
        "is_private": true,
        "name": "something",
        "language": "",
        "utc_last_updated": "2013-02-19 23:30:18+00:00",
        "email_writers": true,
        "no_public_forks": true,
        "resource_uri": "/1.0/repositories/<username>/something"
    }
    

    Cheers, Brian

  6. Anonymous

    Hi,

    I'm using python:

    import urllib.request
    
    params = {"user" : "<username>", "password" : "<password>"}
    
    api = "https://api.bitbucket.org/1.0"
    
    # authentication
    passwordMgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
    passwordMgr.add_password(None, api, params["user"], params["password"])
    handler = urllib.request.HTTPBasicAuthHandler(passwordMgr)
    opener = urllib.request.build_opener(handler)
    urllib.request.install_opener(opener)
    
    # requesting repositories (which works)
    request = urllib.request.Request(api + "/user/repositories");
    reply = urllib.request.urlopen(request)
    print(reply.read())
    
    # creating new repository (which fails)
    values = {"name" : "test123",
            "description" : "repo",
            "is_private" : "true",
                    "scm" : "git"}
    data = urllib.parse.urlencode(values).encode("UTF-8")
    header = {"Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8"}
    request = urllib.request.Request(api + "/repositories", data, header)
    reply = urllib.request.urlopen(request)
    print(reply.read())
    
  7. Anonymous

    Hi,

    I found the problem. This request needs an authorization header otherwise it wont work. Thanks for your help.

  8. Log in to comment