Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Upload attachment to bitbucket server with REST API

Hello,

 

For some time Im trying to find out how to upload an image to Project/Repo/Pull Request using REST API from bitbucket server. The docs Im using is:

https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html

Im starting to lose hope and think its impossible cuz I cant find it.
I have a pretty working mobile app for bitbucket now but Im stuck on creating a comment with an Image/Video/any sort of attachment.

So tell me dear community, is it possible? And if so, how? :D

 

1 answer

1 accepted

1 vote
Answer accepted
Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 23, 2020

Hi @Pastajello ,

 

The attachment REST API became publically available in version 7.0:

https://docs.atlassian.com/bitbucket-server/rest/7.1.2/bitbucket-rest.html#idp192

 

All the best,

Kristy

Hi Kristy and thanks for the answer!

So it seems that its impossible for any older versions of bb server to save attachment by REST, thats somewhat a sad news.

But nevertheless I checked the doc You provided and see that it still lacks the POST in this endpoint. That way I still cant add a screenshot(or anything really) to PR comment.

Cant do a lot with DELETE and GET ;\

"http://example.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/attachments

its endpoints. 

[Sorry, didnt see doubled message]

@Kristy 

From my tweaking it seems that attachments endpoint is available also available on the BB Server in 6.10 version. But I dont see it in documentation.

It DOES have a POST but I cant figure out the way that my request should be formed for it to accept my file.

When I send POST on :

<baseUrl>/projects/<projName>/repos/<repoSlug>/attachments

 

I get

<body>    <h1>HTTP Status 415 – Unsupported Media Type</h1>    <hr class="line" />    <p><b>Type</b> Status Report</p>    <p><b>Description</b> The origin server is refusing to service the request because the payload is in a format not        supported by this method on the target resource.</p>    <hr class="line" /></body>

but when I use GET it says that the method is not supported indicating that SOMETHING is out there :|

 

Could You please help me find out how to make a successful POST to this hidden endpoint? :D

Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 26, 2020

Hi @Pastajello

It is available but not documented because it is private API. This means that Bitbucket Server makes no guarantees about it - it might change in future releases of Bitbucket Server without warning.

If you are making a plugin or something that is expected to be reliable, then you should not be using private API.

 

That said, the problem you're seeing might be because you're using a POST instead of a PUT?

The best way to discover this what the endpoint needs would be to inspect the the network traffic from your browser. Most browser devtools have a 'copy as curl' option which you can use.

 

All the best,

Kristy

Hi,

I have the same issue - when using POST <baseUrl>/projects/<projName>/repos/<repoSlug>/attachments, I receive error 405 method not allowed. I inpected the network tab and for uploading files the same POST endpoint is used.

I see the initial question i 2 years old.. is there a solution yet?

Regards!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events