Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence : Moving an attachment using Cloud REST API

Supreetha Upadhya April 10, 2017 edited

I'd like to move an attachment to a different space (i.e, update the parent container of an attachment in a Confluence page) using Cloud REST API and "curl" command. I looked up REST API endpoint URL and found this: 

PUT /rest/api/content/{id}/child/attachment/{attachmentId}

Could somebody provide an example for a correctly constructed JSON input to achieve this? I tried the one below to move an attachment called "test.jpeg" with ID "att000" and current version 5 to parent with ID 1234, but it fails:

curl -v -u 'admin:password' -X PUT -H 'Content-Type:application/json' -d '{"id":"att000","type":"attachment","title":"test.jpeg","version":{"number":5,"minorEdit":false},"ancestors":[{"id":1234}]' -H ‘X-Atlassian-Token:access-token' https://test.atlassian.net/wiki/rest/api/content/170234/child/attachment | python -m json.tool

Given below is the error message

< HTTP/1.1 415 Unsupported Media Type
.
.
.
No JSON object could be decoded

Thank you for your time!

1 answer

0 votes
Clemens Jütte May 17, 2017

Hello Supreetha!

Have a look at this documentation: https://docs.atlassian.com/confluence/REST/latest/#content/{id}/child/attachment-createAttachments

Your media-type is wrong - you shouldn't be seding JSON around for an attachment. Example curl requests and explanation are in the documentation link.

Cheers!
jay

Suggest an answer

Log in or Sign up to answer
TAGS
Atlassian, Team '25 Europe, Atlassian conference, AI-powered teamwork, Atlassian events, keynote speakers, Barcelona tech conference, Atlassian Williams Racing, Carlos Sainz, Jenson Button, Mike Cannon-Brookes, Anu Bharadwaj, Atlassian Rovo

Atlassian Williams Racing is coming to Team '25 Europe 🏎️

Discover the teamwork and precision behind success on and off the track. See how this high-performing team makes the impossible possible. Be one of the first 100 customers to register for a chance to win 2 tickets to an Atlassian Williams 2026 race.

Register now
AUG Leaders

Atlassian Community Events