Actions
Defect #13713
closedFile attachment is broken with REST API XML format
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Affected version:
Description
example case
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> <description>An optional description here</description> <content_type>image/png</content_type> </upload> </uploads> </issue>
in 'app/controllers/issues_controller.rb'
params[:issue][:uploads] # => [{"upload"=>{"content_type"=>"image/png", "description"=>"An optional description here", "filename"=>"image.png", "token"=>"7167.ed1ccdb093229ca1bd0b043618d88743"}}}
so, never be true in 'lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb'
elsif token = attachment['token']
attachment['upload']['token'] is true
Updated by Etienne Massip over 11 years ago
- Subject changed from REST API issue cannot attach files to File attachment is broken with REST API XML format
Which Redmine version? Any plugin installed?
Updated by TANUKI M over 11 years ago
My environment is as follows.
Environment: Redmine version 2.3.0.devel.11710 Ruby version 1.9.3 (i686-linux) Rails version 3.2.13 Environment production Database adapter Mysql2 Redmine plugins: no plugin installed
Updated by TANUKI M over 11 years ago
Sorry, I'm afraid that this is my mistake.
I used ActiveResource for test.
require 'rubygems'
require 'active_resource'
class Issue < ActiveResource::Base
self.site = 'http://localhost/redmine'
self.user = 'rest'
self.password = 'rest'
end
token = "7167.ed1ccdb093229ca1bd0b043618d88743"
issue = Issue.new(
:subject => 'REST API',
:assigned_to_id => 1,
:project_id => 1,
:uploads => [ {"token" => token, "filename" => "test"} ]
)
puts "*** issue(before)"
puts issue.to_xml
issue.save
issue.to_xml
<?xml version="1.0" encoding="UTF-8"?> <issue> <assigned-to-id type="integer">1</assigned-to-id> <project-id type="integer">1</project-id> <subject>REST API</subject> <uploads type="array"> <upload> <id nil="true"></id> <token>7167.ed1ccdb093229ca1bd0b043618d88743</token> </upload> </uploads> </issue>
Parameters: {"issue"=>{"assigned_to_id"=>1, "project_id"=>1, "subject"=>"REST API", "uploads"=>[{"upload"=>{"filename"=>"test", "token"=>"7167.ed1ccdb093229ca1bd0b043618d88743"}}]}}
ok code is as follows.
#:
issue = Issue.new(
:subject => 'REST API',
:assigned_to_id => 1,
:project_id => 1
)
issue.uploads = [ {"token" => token, "filename" => "test"} ]
#:
Parameters: {"issue"=>{"assigned_to_id"=>1, "project_id"=>1, "subject"=>"REST API", "uploads"=>[{"token"=>"7167.ed1ccdb093229ca1bd0b043618d88743", "filename"=>"test"}]}}
parameter "uploads" is different
Updated by Etienne Massip over 11 years ago
Can you confirm I can close the issue?
What gives issue.to_xml
in the working example?
Updated by TANUKI M over 11 years ago
Etienne Massip wrote:
Can you confirm I can close the issue?
Please close.
What gives
issue.to_xml
in the working example?
same xml...
<?xml version="1.0" encoding="UTF-8"?> <issue> <assigned-to-id type="integer">1</assigned-to-id> <project-id type="integer">1</project-id> <subject>REST API</subject> <uploads type="array"> <upload> <token>7167.ed1ccdb093229ca1bd0b043618d88743</token> <filename>test</filename> </upload> </uploads> </issue>
Updated by Daniel Felix over 11 years ago
- Status changed from New to Closed
Closed by author demand. Thanks for your Feedback.
Actions