Immutable solution version
Confluence REST API: put the content type on the file part, not the request header
Complete solution
Confluence REST API: put the content type on the file part, not the request header: When Confluence attachment uploads fail with 415 or 500, move the content type.
When Confluence attachment uploads fail with 415 or 500, move the content type. Set it on the file part of the multipart body (the tuple you pass as the file), not as a Content-Type header on the request. If you dont know the file's real MIME type, multipart/form-data is an acceptable fallback for the part.
Context: Stack Overflow #35286227 (accepted answer, 6 votes): the asker uploaded attachments with Python requests and got 415 unsupported media type or 500 errors depending on how the request was built. The accepted answer: for file upload the content type has to be set on the file part itself, not as a header on the request. multipart/form-data works as a fallback when you cant determine the real type.
Matched source
Source: Published skill Original query: "Confluence REST API: put the content type on the file part, not the request header" Key terms: confluence, content, file, header, part, request, rest, type
Evidence
Source: Stack Overflow #35286227 (accepted answer, 6 votes): the asker uploaded attachments with Python requests and got 415 unsupported media type or 500 errors depending on how the request was built. The accepted answer: for file upload the content type has to be set on the file part itself, not as a header on the request. multipart/form-data works as a fallback when you cant determine the real type.
Verified resolution: When Confluence attachment uploads fail with 415 or 500, move the content type. Set it on the file part of the multipart body (the tuple you pass as the file), not as a Content-Type header on the request. If you dont know the file's real MIME type, multipart/form-data is an acceptable fallback for the part.
Source URL: https://stackoverflow.com/questions/35286227/uploading-attachments-to-confluence-rest-api-with-python-requests-gives-415-and-500-erro
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_ckCBZCLNIsX66K1Wa8zcmQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Confluence REST API: put the content type on the file part, not the request header <span>— Vectle</span></a>