Uploading attachment via REST API breaks filename

I’m trying to upload attachments to a Confluence page.
I use the REST API /wiki/rest/api/content/{id}/child/attachment on this document.

I call it with curl like this.

curl -D- -v -u email:password -X PUT -H 'X-Atlassian-Token: nocheck' -F 'file=@"test.txt"' -F 'minorEdit="true"' https://site-name.atlassian.net/wiki/rest/api

When I upload attachments via the API, the filenames on the page are broken while filenames on the attachment screen are correct.

On page

On attachment Screen

What should I do to correct it?

I assume the update to the attachment won’t show the original filename as there is now a new version. The file is probably saved with an id and that’s probably what you’re seeing here.

This feels like it’s by design.


Hi @takafumiohtake ,

I’ve created a sample app that can add attachments to pages, but I haven’t seen malformed attachment names. Can you see if you have the issue when you try the following:

  1. Install my app with the URL https://dx-page-attachment-adder.glitch.me/connect.json.
  2. Visit any page.
  3. Click the … menu at the top right.
  4. Click the “Add attachment to this page” menu item.
  5. Select the attachment.
  6. Click the “Add attachment to this page” link.
  7. Edit the page and type “/attach” and click the Attachments from the popup window.
  8. Observe the attachments listed.

How are you adding filenames to the page?


1 Like

Hi @dmorrow ,

Thank you for your reply.

I reproduced the problem with your demo app.
Could you please try this?

  1. Create a new page.
  2. Drag&Drop a file to attach it to the page.
  3. Publish the page.
  4. Click the “Add attachment to this page” menu item of your demo app.
  5. Select the file which has the same filename as step 2.
  6. Click the “Add attachment to this page” link.
  7. The filename on the page is broken.


Hi @rwhitbeck

Thank you for your reply.

This problem only occurs when attach files via Rest API.
So, I think this is a problem of Rest API.

When I attach new file via Confluence UI, the filename is kept.