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

Why Unsupported Media Type Error when attaching xlsx file to Confluence?

Marisa Voss Apr 10, 2018

Disclaimer: I've left certain information out of the code to be kept anonymous. Also using python3 with a combination of modules like pandas, openpyxl, StyleFrame, xlrd and xlwt for formatting the Excel sheet. 

Every time I try to change the headers or media-type Confluence does not accept it. I know that I'm in the right space as far as Confluence is concerned. The file is not corrupted since I can open it in Excel. If anyone can help me on this I would greatly appreciate it. 

My code is below: 

req = requests.Session()
base_url = url
att = {'file': open("items-list2.xlsx", 'rb')}
headers = {"X-Atlassian-Token": "nocheck", "Content_Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "X-Content-Type-Options": "nosniff", "Accept" : "application/json"}
print("base: {} with spreadsheetml.sheet".format(base_url))
attID = 'myAttID'
r = req.get('{}/content/{}'.format(base_url, attID), headers=headers, auth = (username, password), files = att)

if (r.status_code < 300):

print(" ")
print('~~~~ failed to upload file ~~~~')


The Error I receive: 

<Response [415]>
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.48 - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;} {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 415 - Unsupported Media Type</h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u>Unsupported Media Type</u></p><p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</u></p><hr class="line"><h3>Apache Tomcat/8.0.48</h3></body></html>

~~~~ failed to upload file ~~~~

2 answers

1 accepted

1 vote
Answer accepted
Nic Brough [Adaptavist] Community Leader Apr 25, 2018

It looks like Kenny may have found an answer for a different application, and probably posted a link that would not really have helped you.

I'm afraid I don't know the right answer either, but I do know that there is nothing wrong with your file or process, as I've run into the same thing.  It is definitely something in your headers, and of them it is either the Content_Type and/or X-Content-Type-Options.

But as I typed that, I realised the most likely culprit!  Try Content-Type, not Content_Type  (if it's not that, then have another look at the values in those two)

Marisa Voss Apr 26, 2018 • edited

You right! Content-Type was definitely the problem. When a typo is the hardest bug to find smh.

Thank you. 

0 votes
Kenny Ng Atlassian Team Apr 17, 2018 • edited
  • removed as is incorrect
Marisa Voss Apr 18, 2018

What is correct?

Marisa Voss Apr 25, 2018

@Kenny Ng Can you be more specific as to what is wrong and what you removed please? 

Kenny Ng Atlassian Team May 01, 2018

@Marisa Voss sorry that it took me too long to get back to you as it my fault that my . activity feed got flooded and its my fault. Yes, @Nic Brough [Adaptavist] was right. I got the wrong document for a different product and we are glad that you were able to resolve the issue on your end. 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

2,439 views 11 28
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