I cannot create new issue through with REST API
Added by Tom Katsuki over 8 years ago
I'm troubled with redmine.
When I create new issue with Rest API, Internal Error 500 happened. Seeing from production.log, "NoMethodError" is happened (see below message)
Started POST "/redmine/issues.xml?key=XXXXXXX" for XX.XX.XX.XXX at 2016-05-30 14:44:10 +0900 Processing by IssuesController#create as XML Parameters: {"issue"=>` {"project_id"=>"mt001", "subject"=>"TEST_AI", "tracker_id"=>"6", "category_id"=>"136", "assigned_to_id"=>"4", "fixed_version_id"=>"93", "priority_id"=>"2", "parent_issue_id"=>nil, "start_date"=>"2016-05-30", "due_date"=>"2016-06-01", "description"=>"Redmine TEST AI", "status_id"=>"1"}, "key"=>"XXXXXXX(hidden for security"} Current user: user1 (id=65) Completed 500 Internal Server Error in 367ms (ActiveRecord: 19.9ms) NoMethodError (undefined method `shared_versions' for nil:NilClass): app/models/issue.rb:823:in `assignable_versions' app/models/issue.rb:643:in `validate_issue' app/controllers/issues_controller.rb:141:in `create' lib/redmine/sudo_mode.rb:63:in `sudo_mode'
So, I tried to create new issew using web browser (IE11). The ticket was created normally. Here is production.log.
Started POST "/redmine/projects/mt001/issues" for XX.XX.XX.XXX at 2016-05-30 14:58:23 +0900 Processing by IssuesController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"QF1BA5MgwysJsAiFfT/h95DeZ/VgzSGOnryR6xUn4mmWpf7EZ8XFJqpaye/ZLXrKR/wV00dKOz8KbhP94VcUyg==", "form_update_triggered_by"=>"", "issue"=>{"tracker_id"=>"6", "subject"=>"Test2", "description"=>"This is test", "status_id"=>"1", "priority_id"=>"2", "assigned_to_id"=>"4", "category_id"=>"132", "fixed_version_id"=>"127", "parent_issue_id"=>"", "start_date"=>"2016-05-30", "due_date"=>"2016-06-03", "custom_field_values"=>{"12"=>"", "41"=>""}}, "was_default_status"=>"1", "commit"=>"create", "project_id"=>"mt001"} Current user: user1 (id=65) Rendered mailer/_issue.text.erb (7.1ms) Rendered mailer/issue_add.text.erb within layouts/mailer (9.8ms) Rendered mailer/_issue.html.erb (3.0ms) Rendered mailer/issue_add.html.erb within layouts/mailer (5.1ms) Redirected to http://mydepartment.co.jp/redmine/issues/1717 Completed 302 Found in 3697ms (ActiveRecord: 130.3ms)
So I add "Nil Judgement" like this.
def assignable_versions return @assignable_versions if @assignable_versions # Add Nil Judgement versions = project.shared_versions.open.to_a *unless project.nil?* ... #Add Nil Judgement @assignable_versions = versions.uniq.sort *unless versions.nil?* end
"assignable_version" is called in "validate_issue".
After this modification, the another error is occured in "validate_issue".
Here is error sentense.
if !assignable_versions.include?(fixed_version)
Of cource, "assignable_versions" must be nil, error happen surely.
I already tried to migrate, clear cache. What should I do next.
Here is my environment on RHEL7.2
Environment: Redmine version 3.2.0.stable Ruby version 2.2.4-p230 (2015-12-16) [x86_64-linux] Rails version 4.2.5 Environment production Database adapter Mysql2 SCM: Subversion 1.7.14 Git 1.8.3.1 Filesystem Redmine plugins: redmine_export_with_journals 0.0.8 redmine_importer 1.2.2 redmine_local_avatars 1.0.0 redmine_xlsx_format_issue_exporter 0.1.2 sidebar_hide 0.0.7