New-SnipeITuser returns 422
Context
I am Trying to create a new user in snipe-it via New-SnipeITUSer
Your Environment
- SnipitPS Module version used: 1.10.227
- Operating System and PowerShell version: Windows 10, PS 5
- Snipe It version: v6.0.10 build 8673 (gc6cbf3712)
Expected Behavior
New-snipeituser should create a new user when the mandatory fields are filled out (First name, Last Name & UserName)
Current Behavior
When running new-snipeituser without attributes, it prompts for FN, LN and UN. After completing those fields the following error happens.
When running new-snipeituser with attributes -first_name "test" -last_name "tester" -username "ttester" the same error happens
IsMutuallyAuthenticated : False Cookies : {worldsurfleague_snipeitv6_session=gdOZUqYgXJWUGeruiuXyG5tdA1NG RiyGRRXwL4fu} Headers : {Transfer-Encoding, Connection, X-RateLimit-Limit, X-RateLimit-Remaining...} SupportsHeaders : True ContentLength : -1 ContentEncoding : ContentType : application/json CharacterSet : Server : nginx LastModified : 9/29/2022 9:46:16 AM StatusCode : 422 StatusDescription : Unprocessable Content ProtocolVersion : 1.1 ResponseUri : https://worldsurfleague.snipe-it.io/api/v1/users Method : POST IsFromCache : False
Possible Solution
Steps to Reproduce (for bugs)
- new-snipeituser -first_name "test" -last_name "tester" -username "ttester"
Thanks for repoting this . I'll look at this as soon I have time.
I'm also having this issue, unable to create a user, behaviour as reported above.
Verbose output: VERBOSE: Performing the operation "New-SnipeitUser" on target "ShouldProcess?". VERBOSE: [Invoke-SnipeitMethod] Invoking method post to URI VERBOSE: POST with -1-byte payload VERBOSE: [Invoke-SnipeitMethod] Failed to get an answer from the server VERBOSE: [Invoke-SnipeitMethod] Status code: 422 VERBOSE: System.Net.HttpWebResponse VERBOSE: Status: VERBOSE: Messages: VERBOSE: [Invoke-SnipeitMethod] Function ended
It seems that password have to be specified for snipeit api, even user is not activated. So "password" should be mandatory parameter in New-snipeitUser too. Before that is changed just add -password parameter to your command and you are good to go.
Sorry for the very late response but that indeed works. Thankyou very much for clearing this up, has been working flawlessly for a couple of months now.