Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

"Unsupported Media Type" when trying to upload a zip file to a Confluence page using Rest Api

dtrotta I'm New Here Dec 22, 2021

I'm trying to upload a zip file to a Confluence page with a axios.post and I'm getting "Unsupported Media Type" error. I'm following the instructions from Atlassian Development REST API documentation. Does anyone know why I'm having this issue? Any help is appreciated, thanks! This is my code:

 

axios.post('http://example.com/rest/api/content/1234/child/attachment
', {

file: "filepath/namefile.zip",
comment: "comment to file"

}, {

headers: {

"X-Atlassian-Token": "no-check",

"Content-Type": "application/zip",

},

auth: { username: "user@user", password: "passwordToken" }

})

.then(res => {

console.log(res)

})

.catch(error => {

console.error(error)

})

 

1 answer

0 votes
Fabian Lim Community Leader Dec 22, 2021

Hi @dtrotta

Welcome to the community!

See if this workaround fixes your issue: https://confluence.atlassian.com/fishkb/rest-api-error-415-unsupported-media-type-313468261.html

Regards

dtrotta I'm New Here Dec 22, 2021

Hi @Fabian Lim 

I tried with:

"Content-Type: application/zip"

 and got the same error, then I tried with:

 

'Content-Type': 'multipart/form-data' 
And got the following error: 
 data: {
statusCode: 500,
message: 'java.lang.RuntimeException: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found'
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

34,609 views 26 118
Read article

Community Events

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

Events near you