Here's what I'm trying:
curl -n -Ss -X PUT -H 'X-Atlassian-Token: nocheck' '-d{"metadata": {"mediaType": "image/svg+xml" }' https://xxx.atlassian.net/wiki/rest/api/content/26509481/child/attachment/att26869829This yields: HTTP Status 415 - Unsupported Media Type
Both the PUT /rest/api/content/{id}/child/attachment/{attachmentId} (after uploading) and POST /rest/api/content/{id}/child/attachment/{attachmentId}/data (while uploading) endpoints claim to be able to update the media type (although it confusingly switches between the media-type and content-type terminology), but neither give any indication of how to do so.
Another method I've tried is setting the Content-Type HTTP header to "image/svg+xml", but this is rejected with an "invalid media type" error.
I can update using the UI just fine.
I also tried the REST API Browser, but like all useful parts of Confluence, it's not available on a cloud install >:[
Community moderators have prevented the ability to post new answers.
The error message you are getting is because you are not setting the Content Type header for the PUT request to application/json. You need to add -H 'Content-Type: application/json' to your curl request. I've included an example below.
curl -n -u admin:admin -X PUT -H 'Content-Type: application/json' -H 'X-Atlassian-Token: nocheck' -d '{"id":"att917507", "version":{"number":1}, "metadata": {"mediaType": "image/svg+xml" }}' http://localhost:1990/confluence/rest/api/content/98310/child/attachment/att917507
That's probably it. I can't test any more, but have a checkmark.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
here is my code to upload an image.. i got 415 status, meaning bad content-type
of course, i longon first using "auth/1/session"
here to upload..
file = "C:\Users\User\Documents\file.jpg"
oRequest.Open("POST", jiraURL)
oRequest.SetRequestHeader("X-Atlassian-Token", "no-check")
oRequest.SetRequestHeader("Content-Disposition", "form-data; name=""file""; filename=""file.jpg""")
oRequest.SetRequestHeader("Content-Type", "image/jpeg; boundary=WebKitFormBoundaryE19zNvXGzXaLvS5C")
oRequest.Send(file)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.