You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm trying to upload a file as an attachment to a Confluence page via the REST API, but I keep getting error 415, which according to this page means "Unsupported Media Type".
I have Confluence Server so I'm going off of this example in Confluence Server's REST API documentation. I've also looked at this from the Confluence Cloud documentation, but it looks basically the same.
I'm using PowerShell; here's my code ('<confluence server>', '<pageID>', and '<basicAuth>' are obviously substitutions):
Invoke-RestMethod `
-Method POST `
-Uri https://<confluence server>/confluence/rest/api/content/<pageID>/child/attachment `
-InFile file.txt `
-Headers @{
Authorization = "Basic <basicAuth>"
}
I've found many of the same/similar questions and most of the answers are to set the correct Content Type. Many of the answers point to this page, which says the same.
I've tried all variations of content types and none of them work:
Nothing is working. The only change happens if I set the content type to simply 'text', then I get a different error:
HTTP Status 400 – Bad Requestbody
It's a plain text file, but ultimately I'll be uploading different file types like docx, etc. so hopefully the content type isn't filetype-specific.
Is there a content type I'd use for any general purpose file upload?
Any help is appreciated.