Feature #7725

REST API for files

Added by Alex Last over 8 years ago. Updated over 2 years ago.

Status:ClosedStart date:2011-02-25
Priority:NormalDue date:
Assignee:-% Done:


Category:REST API
Target version:-


would be nice to have the API to manipulate files remotely.
e.g. to upload new distributives using some automated scripts.

Related issues

Related to Redmine - Feature #18245: Documents REST API New
Related to Redmine - Feature #13800: File REST API New
Related to Redmine - Patch #19116: Files REST API Closed
Duplicated by Redmine - Feature #20404: REST API support for project files (attachments) Closed


#1 Updated by j dlx about 8 years ago

Alexey Skor wrote:

would be nice to have the API to manipulate files remotely.
e.g. to upload new distributives using some automated scripts.

Well for starters even a simple files list would do for me..
right now the only way (i know of) is to filter activity..

May i ask the maintainer/some official to get some word out on the files-API topic?

Reading through all/most threads regarding this topics, i still have no real clue if:

1. such a feature is planned (or at least considered) at all
2. if so, if there's a roadmap or something?


#2 Updated by Gert van Dijk over 7 years ago

Lately, some progress is made on the REST API features like the file attachments - see #8171. However, as far as I can see from the current documentation, it's still not possible to manage a project's 'Files' and 'Documents' using the REST API.

I would also like to see this feature for automated uploading of files; e.g. test builds after automated building in a post-receive/post-commit hook.

#3 Updated by Gert van Dijk over 7 years ago

In the meantime I created a Python script to overcome this. See redmine-file-uploader on GitHub.

I can now upload my builds from the build server to Redmine in the 'Files' section of the project for internal testing/deployment.
For anyone also in need of this; hope this helps.

#4 Updated by Bengt L├╝ers about 6 years ago

The linked script works fine for uploading, but I would like to download files to mirror them in a Git repository. Is there any chance that this will make it into the API, soon or do I have to write something that does the downloading in the same fashion?

#5 Updated by Dmitry Popov about 6 years ago

Thanks, Gert! Your script works like a charm!

But still, API support would be appreciated.

#6 Updated by Dmitry Popov almost 6 years ago

I've rewritten the script in Ruby:

require 'mechanize'

# Replaces \ with / and removes " 

filename    = ARGV[0] || abort('Filename must be specified')
puts "File:              #{filename}" 
url         = ARGV[1] || abort('Redmine URL must be specified')
puts "Redmine URL:       #{url}" 
username    = ARGV[2] || abort('Redmine username must be specified')
puts "Username:          #{username}" 
password    = ARGV[3] || abort('Redmine password must be specified')
puts "Password:          #{'*' * password.length}" 
project     = ARGV[4] || abort('Redmine project must be specified')
puts "Project:           #{project}" 

login_page_path = '/login'
files_page_path = '/projects/' + project + '/files'

agent = Mechanize.new

# No certificate verification (I had to use this hack because our server is bound to custom port)
# agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE

agent.get(URI.join(url, login_page_path)) do |login_page|
  login_page.form_with(:action => login_page_path) do |login_form|
    login_form.username = username
    login_form.password = password

agent.get(URI.join(url, files_page_path + '/new')) do |upload_page|
  upload_page.form_with(:action => files_page_path) do |upload_form|
    upload_form.file_uploads.first.file_name = filename

Here's the script to delete uploaded files:

agent.get(URI.join(url, files_page_path)) do |files_page|
  file_link = files_page.link_with(:text => File.basename(filename))
  if file_link
    file_id = file_link.href.match(/download\/(\d+)/)[1].to_i
    agent.post(URI.join(url, "/attachments/#{file_id}"), {'_method' => 'delete', 'authenticity_token' => files_page.at('meta[@name="csrf-token"]')[:content]})

#7 Updated by Lucile Quirion over 4 years ago

I also need a REST API for uploading files and noted that there is several open tickets concerning that feature (#18245, #13800)

So I've started working on it.
I'll try to include the patch submitted in #13800

#8 Updated by Toshi MARUYAMA over 4 years ago

#9 Updated by Toshi MARUYAMA over 4 years ago

#10 Updated by Toshi MARUYAMA over 4 years ago

#11 Updated by Mischa The Evil almost 4 years ago

  • Duplicated by Feature #20404: REST API support for project files (attachments) added

#12 Updated by Go MAEDA over 2 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

Implemented by #19116, will be available in upcoming 3.4.0.

Also available in: Atom PDF