Post attachment over api with attachment download url

Hi

I am trying to copy an attachment from one page to another. I know that I can get the download uri over a rest api call (https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-attachmentid-data-post)

In the create attachment rest api call (https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-post), it is stated that I only need the path to the attachment and the attachment name. But I have no idea how the ‘file’ object should look like with only those two parameters.
Can someone help? / Give me an example?

Many Thanks
Philipp

1 Like

Hi,
Is the question how to attach the actual file data (from the client) in the request to create a new attachment?

For java, https://www.baeldung.com/unirest is a great tutorial
specifically https://www.baeldung.com/unirest#file-uploads

In postman, In the “body” tab, you should select a “form-data” and be able to add a “Key” named “file” and choose its type as “File” instead of “Text” and select the file to upload.

Hi MilindPatil

(I am trying to copy an attachment from one page to another)

I still don’t know how this file object should look like. In the links above to your rest api documentation you mention that I only need the link of the attachment location to the binary data and the attachment name:

And give this json as example:

I get the location from your download attachment rest api.

But I still don’t know how this file property should look like. Do I need to get the content from the download url (binary data) and create on our side a new file → and write the binary representation of it there (not preferred and seems complicated)? Isn’t it possible to just add the file name and location of the binary data as described in your rest api? How do I do that? How would the file property look like? With for example ‘download_link’ as relative location and ‘attachment example’ as name. (I am using Node.js)

When I add the download link in the file property, I get this error:
Screenshot from 2022-06-29 17-13-42