Forums

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

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

dtrotta
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!
December 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 Champion
December 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
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 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
AUG Leaders

Atlassian Community Events