I am trying to use Redmine's API to create issues, but it doesn't seem to let me specify who is submitting the ticket. I have tried getting author_id
and it doesn't seem to work.
This is what the JSON data in the POST looks like:
{
"issue": {
"author_id": 3,
"project_id": 26,
"subject": "Q-12345678",
"description": "This is a test"
}
}
The issue is being created, but the author is being set to anonymous. Any suggestions?
Well, I figured it out. As it turns out author_id
is not set as a "safe parameter".
I opened up app/models/issue.rb
and added author_id
on line 337.
So now that block of code looks like this:
safe_attributes 'tracker_id',
'status_id',
'category_id',
'author_id',
'assigned_to_id',
'priority_id',
'fixed_version_id',
'subject',
'description',
'start_date',
'due_date',
'done_ratio',
'estimated_hours',
'custom_field_values',
'custom_fields',
'lock_version',
'notes',
:if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:edit_issues, issue.project) }
EDIT
I think this might be a better solution in app/models/issue.rb
(line 375)
After
safe_attributes 'parent_issue_id',
:if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
user.allowed_to?(:manage_subtasks, issue.project)}
I added
safe_attributes 'author_id',
:if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:admin, issue.project)}