I contacted ActiveCollab support, who instructed me to create a post here.
We are running version 7.3.306 and need to upload a file/attachment via the API.
I have been referencing the API Documentation, which instructs me to do a POST to /upload-files, then use the "code" from the response to attach it to a task in a subsequent POST to /projects/<PROJECT ID>/tasks.
I've tried the curl request below, which returns a HTTP 200 with a body of [] instead of the expected response shown in the documentation.
curl --location 'https://<URL OF SELF HOSTED VERSION>/api/v7/upload-files' \
--header 'X-Angie-AuthApiToken: <WORKING TOKEN>' \
--header 'Content-Type: image/png' \
--data '@/path/to/test/png-test.png'
Thoughts on what am I missing?
Turned out to be an issue with the content type. Instead of sending the file as
application/x-www-form-urlencodedin the POST request, it needed to submitted asmultipart/form-data.The curl command above returns JSON which contains a code for the file, which can be used to attach the file to a task:
Further reading on ReqBin explains the differences between the content types and appropriate curl syntax if you're interested.