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

Unable upload file to bitbucket using POST with token

Igal Seagal February 23, 2021

I successfully retrieved a token and able to use GET to retrieve a list of files from https://api.bitbucket.org/2.0/repositories/companyname/project/downloads

But, while using POST in attempt to upload a file I am getting 406 Not Acceptable error

I am using httr:POST function of R

httr::POST("https://api.bitbucket.org/2.0/repositories/companyname/project/downloads",
encode = "multipart",
httr::add_headers(Authorization = token),
body = upload_file("Path_to_file/hello.txt"),
verbose())

The full response is:

-> POST /2.0/repositories/companyname/project/downloads HTTP/1.1
-> Host: api.bitbucket.org
-> User-Agent: libcurl/7.64.1 r-curl/4.3 httr/1.4.1
-> Accept-Encoding: deflate, gzip
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: text/plain
-> Authorization: Bearer YM60jBsTlbN2ZdvJertb2ZjJKBIv62U59umhDN3dTKJnvvM18a7AaF-MIhZWoFYtSSh5ihX4dJws2C0ldPCwKldxDN15e7VvqiZ9cNcRXdveaN7F94wfnyV2Ytf
-> Content-Length: 20
->
>> HelloWorld i am here

<- HTTP/1.1 406 Not Acceptable
<- Server: nginx
<- Vary: Authorization, cookie, user-context
<- Cache-Control: no-cache, no-store, must-revalidate, max-age=0
<- Content-Type: application/json; charset=utf-8
<- X-OAuth-Scopes: pipeline, snippet, wiki, repository:delete, repository:admin, repository:write, project:write
<- X-B3-TraceId: a42dd69cbefe4998
<- X-Dc-Location: ash2
<- Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
<- Date: Tue, 23 Feb 2021 20:29:34 GMT
<- Expires: Tue, 23 Feb 2021 20:29:34 GMT
<- X-Served-By: app-3006
<- X-Static-Version: 28799d1fab09
<- X-Accepted-OAuth-Scopes: repository:write
<- X-Credential-Type: oauth2
<- X-Render-Time: 0.308979034424
<- Connection: Keep-Alive
<- X-Request-Count: 2085
<- X-Frame-Options: SAMEORIGIN
<- X-Version: 28799d1fab09
<- Content-Length: 92
<-

Please, help!

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events