Actions
Defect #15874
closedREST API answers with error 500 when trying to create new user
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Invalid
Affected version:
Description
I have to create new Redmine users from external source, so I want to use REST API.
First, I've created new user - `Automatics` with admin rights. After that I tried to call API from Chrome extension - Postman (HTTP request simulator).
Here is my request:
URL: http://redmine.dev.domain.ru/users.json?key=45fcdf639621f16020dac48f10cee94c545dfc69
Body:
{ "user": { "login": "jplang", "firstname": "Jean-Philippe", "lastname": "Lang", "mail": "jp_lang@yahoo.fr", "password": "secret" } }
And API answer is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <title>Redmine 500 error</title> <style> body{ font-family: Trebuchet MS,Georgia,"Times New Roman",serif; color:#303030; margin:10px; } h1{ font-size:1.5em; } p{ font-size:0.8em; } </style> <body> <h1>Internal error</h1> <p>An error occurred on the page you were trying to access. <br /> If you continue to experience problems please contact your Redmine administrator for assistance. </p> <p>If you are the Redmine administrator, check your log files for details about the error.</p> <p> <a href="javascript:history.back()">Back</a> </p> </body> </html>
I've enabled debug-level logging for Redmine, and log show this:
Started POST "/users.json?key=45fcdf639621f16020dac48f10cee94c545dfc69" for 127.0.0.1 at 2014-01-15 16:56:10 +0400 Processing by UsersController#create as JSON Parameters: {"key"=>"45fcdf639621f16020dac48f10cee94c545dfc69"} (0.1ms) SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings` Token Load (0.1ms) SELECT `tokens`.* FROM `tokens` WHERE `tokens`.`action` = 'api' AND `tokens`.`value` = '45fcdf639621f16020dac48f10cee94c545dfc69' LIMIT 1 User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` = 109 LIMIT 1 Current user: Automatics (id=109) Completed 500 Internal Server Error in 4ms NoMethodError (undefined method `[]' for nil:NilClass): app/controllers/users_controller.rb:89:in `create'
What's wrong and could I fix it somehow?
This is my environments:
Environment: Redmine version 2.3.3.stable Ruby version 1.9.3-p194 (2012-04-20) [x86_64-linux] Rails version 3.2.13 Environment production Database adapter Mysql2 Redmine plugins: redmine_anonymous_watchers 0.1.0 redmine_git_hosting 0.6.2 redmine_plugin_views_revisions 0.0.1
Updated by Andrey Tatarnikov almost 11 years ago
- Status changed from New to Resolved
I forgot Content-type... :(
Now it works.
Updated by Etienne Massip almost 11 years ago
- Status changed from Resolved to Closed
- Priority changed from Urgent to Normal
- Resolution set to Invalid
Actions