Project

General

Profile

Attachments over REST-Api in xml

Added by David Miguel about 12 years ago

hi,

to add a task in redmine, using the rest api,
follow the examples provided it could easily create tasks,
creating a file issues.xml like this,


-<issue>
<project_id>1</project_id>
<tracker_id>1</tracker_id>
<status_id>1</status_id>
<priority_id>1</priority_id>
<author_id>1</author_id>
<start_date>2011-10-09</start_date>
<subject>Created in DELPHI</subject>
<description>Issue created in DELPHI using Redmine REST API</description> -
<custom_fields type="array"> -
<custom_field id="1">
<value>12121212</value>
</custom_field> -<custom_field id="2">
<value>2010-10-09</value>
</custom_field>
</custom_fields>
</issue>

and just using a link like this:

http://localhost:8080/issues.xml?key=a1234567abcde12121a11a123456a12a12ab123ab

the issue is created without problem.

however,
i read the rest api documentation and is failing me anything
how can I upload the file i want to follow this example?

POST /uploads.xml
Content-Type: application/octet-stream
... ????
(request body is the file content)

what link is used to obtain the token upload the file to get the # 201 response

in curl i have no problem but i need over http,
I tried this link and does not work and I do not know how to build uploads.xml

http://localhost:8080/uploads.xml/key?a1234567abcde12121a11a123456a12a12ab123ab

  1. 201 response
    <upload>
    <token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
    </upload>

Then you can use this token to attach your uploaded file to a new or an existing issue.

POST /issues.xml
<issue>
<project_id>1</project_id>
<subject>Creating an issue with a uploaded file</subject>
<uploads type="array">
<upload>
<token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
<filename>image.png</filename>
<content_type>image/png</content_type>
</upload>
</uploads>
</issue>

if someone could help me, I was very grateful.
thanks in advanced


Replies (7)

RE: Attachments over REST-Api in xml - Added by Etienne Massip about 12 years ago

Actually you seems to do all right, what goes wrong?

RE: Attachments over REST-Api in xml - Added by David Miguel about 12 years ago

Not Found

The requested URL /uploads.xml/key was not found on this server.

http://localhost:8080/uploads.xml/key?a1234567abcde12121a11a123456a12a12ab123ab
does not work

i need first upload de file, how do I do that ?

what link is used to obtain the token when file is upload ?

RE: Attachments over REST-Api in xml - Added by David Miguel about 12 years ago

thanks Etienne Massip but if you see all the post i've allready tryed that.

could you make a test and tell me the solution?

best regards

RE: Attachments over REST-Api in xml - Added by Etienne Massip about 12 years ago

David Miguel wrote:

thanks Etienne Massip but if you see all the post i've allready tryed that.

Where that?

Anyway, I don't know how you want to upload your file ; you can do that using a command-line tool such as, e.g., wget --header='Content-Type: application/octet-stream'--post-file=... http://.../uploads.xml on linux.

RE: Attachments over REST-Api in xml - Added by no no about 12 years ago

i have the same problem, the request returns 404. Could it be that there is no such a script "uploads.xml" on the server side? how can i check this? i`m not an admin

RE: Attachments over REST-Api in xml - Added by no no about 12 years ago

no no wrote:

i have the same problem, the request returns 404. Could it be that there is no such a script "uploads.xml" on the server side? how can i check this? i`m not an admin

it seems, my problem was solved by changing header-type to "application/octet-stream". now I get 201-created finally)))

    (1-7/7)