Defect #6373
closedCan't Set author_id When Creating New Issue Through REST API
0%
Description
I have a web form on a separate site that I have been using with the REST API to create new issues successfully. I have only one problem: when using the REST API as shown below, it appears to not use the author_id that I define. Instead, the new issue always ends up having author_id set to the id of the user that is authenticating with the API.
- Issue model on the client side
class Issue < ActiveResource::Base
self.site = 'http://redmine.server/'
self.user = 'foo'
self.password = 'bar'
end
issue = Issue.new(
:subject => 'REST API',
:assigned_to_id => 1,
:project_id => 1,
:author_id => 4 <--- this gets overwritten by id of 'foo'
)
Is setting the author_id not allowable from the REST API or am I missing something? I also tried changing the user and password dynamically with each new request (i.e. issue.user => 'user', issue.password => 'password' before issue.save gets called), without success.
Related issues
Updated by Felix Schäfer over 14 years ago
See source:/trunk/app/controllers/issues_controller.rb#L307, the author of an issue will always be the user hitting the crontroller, be it over html or REST.
Updated by Eric Davis over 14 years ago
- Status changed from New to Closed
- Resolution set to Duplicate
Felix is right. There is a feature request (#1739) for setting author to another user but it's not Redmine yet. (e.g. UserA creates Issue for UserB with UserB as the "author"). Once it's added to Redmine, it will include API access.
I have some code a client is testing out that does this but it's not ready for release quite yet.
Updated by Jean-Philippe Lang almost 12 years ago
Scott Doerrfeld wrote:
Is setting the author_id not allowable from the REST API or am I missing something?
Setting author_id is not allowed. But you can use User-Impersonation when using the API with an admin account.
Updated by Paul Wehle almost 12 years ago
Setting author_id is not allowed. But you can use Rest_api when using the API with an admin account.
Hi Jean-Philippe, sorry I don't understand the meaning of your comment. Could you elaborate please?
In my case I'd like to see who was the user who reported the issue, this is the author of the issue. Since author_id cannot be set through REST API I am not sure how to achieve this.
Even if using Rest_api with an admin account I believe the author_id cannot be set as shown in create_issue request Rest_Issues where this parameter does not exist.
Updated by Jean-Philippe Lang almost 12 years ago
User-Impersonation lets you make a API request as if it was done by another user. You should be able to use it to set the issue author to a different user. You just need to set the X-Redmine-Switch-User
header of your API request to the login of the user that should be the author of the issue.