2

I have some repos in my bitbucket user account and I want them to import to a team I created.

I looked in Bitbucket API references and couldn't find any API which can import a repo from my account to a Team.

So I am trying to write a script which can do the same. I am using robobrowser library.

I am able to fill up the sign in form, sign into my bitbucket. Then I fill up the form which sends a POST request to import.

After I fill up and submit, the response I am receiving back is same as old page which has the form. The response status is 200, but I don't see new imported repos in my bitbucket team.

Here is my code which I am using to login into Bitbucket:

from robobrowser import RoboBrowser
browser = RoboBrowser()
url = 'https://bitbucket.org/account/signin/'
browser.open(url)
signin_form = browser.get_form(id='login-form')
signin_form['username'] = bb_username
signin_form['password'] = bb_password
browser.session.headers['Referer'] = url
# signin_form.serialize() 
browser.submit_form(signin_form)

and this is code which I am using to submit the import-repo form, which is failing:

url = 'https://bitbucket.org/repo/import'
browser.open(url)
import_form = browser.get_form(id='import-form')
import_form['source'] = 'source-git'
import_form['url'] = 'https://github.com/avinassh/talkwithme'
import_form['name'] = 'test-import-repo'
# import_form
browser.submit_form(import_form)

Any idea why this is happening? robobrowser is a very new library, is there any better library with good documentation for my task? Any help is appreciated.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
avi
  • 9,292
  • 11
  • 47
  • 84
  • I use urllib to to scrap webpages which need authentication it is quite easy to use too – Sar009 Feb 13 '14 at 09:19
  • 1
    Looks like you got redirected back; look at `browser.state.response.history`. You could try setting a user agent so see if bitbucket will then accept the login. – Martijn Pieters May 19 '14 at 13:01

0 Answers0