Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload a file and create a new commit using the API?

Enrique Fernández-Polo Puertas
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 1, 2019 edited

Hello!!

I am getting a 500 reponse every time I try to use the example in de documentation.

 

The curl is always returning 500.

curl https://api.bitbucket.org/2.0/repositories/username/slug/src \
  -F /repo/path/to/image.png=@image.png

{"type":"error","error":{"message":"Something went wrong","id":"0488898c2387461f9ed4a29591a38cf2"}}

I have tried absolutes paths, parameters... How can I debug this error??

1 answer

0 votes
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 2, 2019

Hi @Enrique Fernández-Polo Puertas

Thank you for flagging that.
The example in that document page is incomplete. You should use something like:

curl -u <USER>:<APP_PASSWORD> \
    -X POST https://api.bitbucket.org/2.0/repositories/<USER>/<SLUG>/src \
-F <REPO_FILE_NAME>=@"<LOCAL_PATH_TO_FILE>/<FILE_NAME>"

e.g.

curl -u admin:123456 \
    -X POST https://api.bitbucket.org/2.0/repositories/admin/repo/src \
-F avatar.png=@"~/my folder/image.png"


I've raised an internal ticket to flag that we need to fix that page.
Please let me know if you are able to upload the file as you wish.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events