0

I want to upload a file to the "Files" section of a project in Redmine.

I've read the API documentation and were able upload the file and obtain a token with

curl -ik -d "@dummy.txt" -H "Content-Type:application/octet-stream" -X POST https://myredmine.local/uploads.json?filename=dummy.txt&key=mysecretapikey

This request returned e.g.

{"upload":{"id":174152,"token":"177152.17ace63347256470b75443c5aed7607f21fe3b90cc269d642404edb55dd00732"}}

I cannot find out how to create the request that adds the uploaded file to the file section of my project. I know it need to be a POST request to https://myredmine.local/projects/myproj/files.json where myproj is the identifier/slug of my project, but I cannot make it work. I've tried various things, e.g.:

curl -ik -X POST --header "Content-Type: application/json" --data '{"file": {"filename":"dummy.txt", "description":"Test upload via API","content_type": "", "token":"177152.177152.17ace63347256470b75443c5aed7607f21fe3b90cc269d642404edb55dd00732"}}' https://myredmine.local/projects/myproj/files.json?key=mysecretapikey
slarag
  • 153
  • 8
  • Is the files module enabled? Can you create issue via post? – Aleksandar Pavić Aug 24 '23 at 05:59
  • Yes, after uploading the file I can create an issue via REST API with the file attached: `curl -ik -X POST --header "Content-Type: application/json" --data '{"issue": { "project_id": "myproj", "subject": "Test: Create issue with file via API", "uploads": [{"token": "177152.17ace63347256470b75443c5aed7607f21fe3b90cc269d642404edb55dd00732", "filename": "dummy.txt", "content_type": "text/plain"}]}}' https://myredmine.local/issues.json?key=mysecretapikey` – slarag Aug 24 '23 at 08:48

0 Answers0