Sebastian Tänzer Sebastian Tänzer - 7 months ago 70
reST (reStructuredText) Question

activeCollab API: Post multiple files

I'm using a self hosted activeCollab 5 setup and am trying to upload multiple files via /upload-files. I am sending a multipart form POST with each part name named "attachment_1", "attachment_2" and so on. Unfortunately only the first file in my request named attachment_1 is beeing used and returns the file code response.

What is the correct way to upload multiple files through the API (without the SDK - our application is using Ruby ond Rails) at once?



I am a PHP developer.

Had the same problem and here's how I solved it:

From inside the post method:

if (is_array($file)) {
    list($path, $mime_type) = $file;


In PHP 5, list() assigns the values starting with the right-most parameter. In PHP 7, list() starts with the left-most parameter. I'm using php 5.6 so I swapped:

['/path/to/file.png' => 'image/png']


['image/png' => '/path/to/file.png']

Works as intended now.