SnipeitPS icon indicating copy to clipboard operation
SnipeitPS copied to clipboard

New-SnipeITuser returns 422

Open cphillipsWSL opened this issue 4 years ago • 4 comments

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)

  1. new-snipeituser -first_name "test" -last_name "tester" -username "ttester"

cphillipsWSL avatar Sep 29 '22 16:09 cphillipsWSL

Thanks for repoting this . I'll look at this as soon I have time.

PetriAsi avatar Oct 06 '22 16:10 PetriAsi

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

FireLucid avatar Nov 15 '22 22:11 FireLucid

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.

PetriAsi avatar Nov 29 '22 03:11 PetriAsi

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.

FireLucid avatar Jun 01 '23 03:06 FireLucid