So I have been struggling with this for a while now.
I need to simply download a file from a private repo using python (I want to use this file later on the same python script).
Due to the lack of documentation (and all my failed attempts) now I'm simply trying to make it work via curl. I switched to curl as a way of finding the right structure (there's a lot more issues on internet using curl than python) to later be able to translate it into python.
But still no luck. I've tried:
curl -O -u username:password https://bitbucket.org/username/repository/raw/branch/filename.txt
curl --user email@example.com:password "https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt
with no luck.
When it says password in the curl commands I've used an app password that has read access to the repo.
So can anyone point me in the right direction? At this point I dont care if it's Python or curl :)
Hello @Martí Bastida Comas
Thank you reaching out Atlassian Community.
Can you please try the following curl command?
curl -u username:password https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt -o file.txt
Hi, thanks for your response.
This command at least doesn't give an error:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
But still the file downloaded is blank, There's nothing in it.
Can you send the command with -v flag to see verbose output?
curl -u username:password https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt -o file.txt -v
Great the problem was mine. I was input the email instead of the username.
Now it works.
One last thing: Could you point me the specific page where this endpoint is documented? It's probably me but if i search the bitbucket 2.0 REST API I can't find this. I ask it because I will need other info (like list the directories in a folder) and I don't want to have to open a question for each endpoint :)
That's where I was looking for. But for example, the endpoint you have given me is not listed on the repositories section. The closest one is the Get a repository endpoint. Is this correct or I'm looking somewhere not right?
How could one (for example) list all the directories in a specific folder?
Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events