ShareFile-PowerShell icon indicating copy to clipboard operation
ShareFile-PowerShell copied to clipboard

Send-SfRequest : BadRequest: User must be added as an employee.

Open eddison414 opened this issue 4 years ago • 2 comments

I'm trying to create an employee account (not a client) but I always get the same error. I'm not sure what am I doing wrong. When I put some domain of my company, I get the error. When a put a different domain like "@gmail.com" it does work.

Add-PSSnapin sharefile
$sfClient =  Get-SfClient -Name "C:\Users\user\Documents\MySubdomain.sfps"

#create contact in ShareFile
$user = New-Object ShareFile.Api.Models.AccountUser

#required fields
$user.FirstName = "testuser"
$user.LastName = "shafiletest"
$user.Email = "[email protected]"

#create client user
Send-SfRequest $sfClient `
               -Method POST `
               -Entity users `
               -Body $user `
               -Parameters @{"addshared" = "true"}

eddison414 avatar Sep 20 '21 18:09 eddison414

You have the wrong Entity. Also, the "addshared" is obsolete (will always be true) and is unnecessary. If you want an example, you can look at this Gist.

jstrong013 avatar Sep 26 '21 02:09 jstrong013

Thank you so much!!! this did it for me

eddison414 avatar Oct 04 '21 20:10 eddison414