Please help. I've looked at the API, but this is still not working. 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()
print("Hello")
url='https://confluence.<mycompany>.com/rest/api'
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(r.headers)
print(r)
print(r.text)
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;}A.name {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 ~~~~
@Marisa Voss It looks like the issue is resolve on another page.
I will mark this as answer to help other community if they have stumble on to this thread.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.