Project

General

Profile

REST api and duplicate issue

Added by Rodrigo Araujo almost 14 years ago

I'd like to create recurring tasks in my redmine. So I'm trying to create a script that run with cron to do that.

I successful retrive and update issues using REST api from redmine trunk. (http://www.redmine.org/wiki/redmine/Rest_api_with_ruby), but I got this code:

...
issue = Issue.find(1)

issue_duplicated = Issue.new(
  :copy_from => issue
)
if issue_duplicated.save
  puts issue_duplicated.id
else
  puts issue_duplicated.errors.full_messages
end

I get this error:
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:31:in `to_sym': interning empty string (ArgumentError)
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:31:in `tag!'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/hash/conversions.rb:141:in `to_xml'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/hash/conversions.rb:110:in `each'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/hash/conversions.rb:110:in `to_xml'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:134:in `call'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:134:in `_nested_structures'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb:58:in `method_missing'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/hash/conversions.rb:109:in `__send__'
         ... 12 levels...
        from c:/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.8/lib/active_resource/base.rb:1084:in `create'
        from c:/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.8/lib/active_resource/base.rb:867:in `save_without_validation'
        from c:/ruby/lib/ruby/gems/1.8/gems/activeresource-2.3.8/lib/active_resource/validations.rb:259:in `save'
        from teste_rest.rb:27

Can anyone help me?

Ps1.: I need to change a due_date too, but I don't know how to do this

Ps2.: It's my first ruby hack