Defect #6403
closedUpdating an issue with custom fields fails
0%
Description
If I run the following code
require 'rubygems'
require 'active_resource'
# Issue model on the client side
class Issue < ActiveResource::Base
self.site = 'http://redmine.server/'
self.user = 'foo'
self.password = 'bar'
end
# Updating an issue
issue = Issue.find(1)
issue.subject = 'REST API'
issue.save
it fails on issue.save with the following error
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/array/conversions.rb:163:in `to_xml': Not all elements respond to to_xml (RuntimeError)
I suspect it has something to do with custom fields because if I do
# Updating an issue
issue = Issue.find(1)
issue.subject = 'REST API'
issue.custom_fields = nil
issue.save
it works !
Related issues
Updated by Ward V about 14 years ago
I can confirm this - I'm seeing the same thing. It's the custom_fields that cause this.
Updated by Stéphane Dubois about 14 years ago
Something strange:
to create an issue with a custom field we do
issue = Issue.new(
:subject => 'REST API',
:assigned_to_id => 1,
:project_id => 1,
:custom_field_values => {'2' => 'Fixed'}
)
issue.save
but when I retrieve an issue with REST API, :custom_field_values is not an entry of the attributes hash. Instead, I have a :custom_fields entry containing a custom_field entry which is an array containing all custom fields values.
If a try to update one of those values like that
issue = Issue.find(1)
issue.custom_fields.custom_field[0] = dummy_value
issue.save
I get the same error
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/array/conversions.rb:163:in `to_xml': Not all elements respond to to_xml (RuntimeError)
So, I can't find a way to update a custom field.
Updated by Stéphane Dubois about 14 years ago
In fact, it's possible to update a custom fields with the same hash than for creation, but you must also nilify custom_fields
issue = Issue.find(1)
issue.custom_field_values = {'1' => 'dummy'}
issue.custom_fields = nil
issue.save
Updated by Eric Davis almost 14 years ago
- Assignee deleted (
Eric Davis)
I am stepping down from working on Redmine. If someone else is interesting in working on this issue, feel free to reassign it to them.
Eric Davis
Updated by Jean-Philippe Lang almost 14 years ago
Stéphane Dubois wrote:
In fact, it's possible to update a custom fields with the same hash than for creation, but you must also nilify custom_fields
[...]
I don't know which version you're using but I can't reproduce this problem with current trunk. The following works:
issue = Issue.find(1)
issue.custom_field_values = {'1' => 'dummy'}
issue.save
Updated by Jean-Philippe Lang almost 14 years ago
- Assignee set to Jean-Philippe Lang
- Target version set to 1.0.5
- Affected version (unused) set to 1.0.4
- Affected version set to 1.0.4
Problem found. The fix requires a slight change in the custom fields part of the API.
Updated by Jean-Philippe Lang almost 14 years ago
- Status changed from New to Resolved
- Resolution set to Fixed
Updated by Jean-Philippe Lang almost 14 years ago
- Status changed from Resolved to Closed
- Target version changed from 1.0.5 to 1.1.0
It will have to wait 1.1.0 because it relies on changes done in trunk only.