{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef/issues/3010","labels_url":"https://api.github.com/repos/chef/chef/issues/3010/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/3010/comments","events_url":"https://api.github.com/repos/chef/chef/issues/3010/events","html_url":"https://github.com/chef/chef/issues/3010","id":59700191,"number":3010,"title":"Knife user creation doesn't work in Chef 12","user":{"login":"luckymike","id":479368,"avatar_url":"https://avatars.githubusercontent.com/u/479368?v=3","gravatar_id":"","url":"https://api.github.com/users/luckymike","html_url":"https://github.com/luckymike","followers_url":"https://api.github.com/users/luckymike/followers","following_url":"https://api.github.com/users/luckymike/following{/other_user}","gists_url":"https://api.github.com/users/luckymike/gists{/gist_id}","starred_url":"https://api.github.com/users/luckymike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luckymike/subscriptions","organizations_url":"https://api.github.com/users/luckymike/orgs","repos_url":"https://api.github.com/users/luckymike/repos","events_url":"https://api.github.com/users/luckymike/events{/privacy}","received_events_url":"https://api.github.com/users/luckymike/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-03T20:26:11Z","updated_at":"2015-03-25T10:38:07Z","closed_at":null,"body":"```\r\nknife user create foo --admin -p xxxxxxxxxxxxxxxx\r\n```\r\nOpens an editor with the following:\r\n```\r\n{\r\n  \"name\": \"foo\",\r\n  \"public_key\": null,\r\n  \"admin\": true,\r\n  \"password\": \"xxxxxxxxxxxxxxxx\"\r\n}\r\n```   \r\nSaving gives this error:\r\n```                                          \r\nERROR: The data in your request was invalid\r\nResponse: Field 'username' missing\r\n```\r\nChanging `name` to `username` then saving results in the same error.\r\n"},"comment":{"url":"https://api.github.com/repos/chef/chef/issues/comments/85976441","html_url":"https://github.com/chef/chef/issues/3010#issuecomment-85976441","issue_url":"https://api.github.com/repos/chef/chef/issues/3010","id":85976441,"user":{"login":"stevendanna","id":852371,"avatar_url":"https://avatars.githubusercontent.com/u/852371?v=3","gravatar_id":"","url":"https://api.github.com/users/stevendanna","html_url":"https://github.com/stevendanna","followers_url":"https://api.github.com/users/stevendanna/followers","following_url":"https://api.github.com/users/stevendanna/following{/other_user}","gists_url":"https://api.github.com/users/stevendanna/gists{/gist_id}","starred_url":"https://api.github.com/users/stevendanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevendanna/subscriptions","organizations_url":"https://api.github.com/users/stevendanna/orgs","repos_url":"https://api.github.com/users/stevendanna/repos","events_url":"https://api.github.com/users/stevendanna/events{/privacy}","received_events_url":"https://api.github.com/users/stevendanna/received_events","type":"User","site_admin":false},"created_at":"2015-03-25T10:38:06Z","updated_at":"2015-03-25T10:38:06Z","body":"The short answer: You probably want to either (1) use chef-server-ctl user-create or (2) temporarily configure your knife client to such that the chef_server_url is the root of the chef server (no \"organization/ORGNAME\" in the URL) and the client is pivotal.\r\n\r\nIn Chef 11 Server: This command should work as expected.\r\n\r\nIn Chef 12 Server: Whether `knife user create` will work depends on the user making the request and the chef_server_url.  Chef 12 has the following user endpoints that expect POST:\r\n\r\n- `POST /users`:\r\n\r\nThis endpoint creates a new user.  With `chef_server_url` set to the root of your Chef server, and using the pivotal user, this command should work without modification.\r\n\r\n- `POST /organizations/ORGNAME/users`:\r\n\r\nThis endpoint force-associates an *existing* user with an organization (without the user accepting the invite).  This only works for the pivotal user.  The expected POST body is:\r\n\r\n    { \"username\": \"USERNAME\" }\r\n\r\n`knife user create` does not post the raw JSON that you enter into the editor.  Rather, it uses it to construct a valid Chef::User object where the name field is \"name\" and not \"username\".  In fact, it looks like it will probably ignore the username field altogether and will always pass the \"name\" field which isn't accepted by the organization-specific version of this endpoint.\r\n\r\n\r\n\r\n"}}