Jump to content
Welcome to our new Citrix community!
  • 0

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


Eddison Razon

Question

Hello,

I'm trying to create a new Citrix sharefile user base on this documentation

Link: https://github.com/citrix/ShareFile-PowerShell/blob/master/Samples/CreateUsers.ps1

 

$sfClient = New-SfClient -Name "C:\Users\me\Documents\MySubdomain.sfps"

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

#required fields
$user.FirstName = "testuser"

$user.LastName = "regulartest"
$user.Email = "tregulartest@domain.com"

#optional fields
$user.Company = "domainname"



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

}

 

I'm getting the following error;

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

At line:1 char:9

+ Send-SfRequest $sfClient -Method GET -Entity Users -Body $us ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (Users:String) [Send-SfRequest], Exception

+ FullyQualifiedErrorId : BadRequest,ShareFile.Api.Powershell.SendSfRequest

 

 

I'm not quite sure what am I doing wrong

Link to comment

3 answers to this question

Recommended Posts

  • 0

Based on the error message, I think the issue might be that you have are attempting to create an user whose email address domain matches your account domain (or account employee domain).  If the user email domain matches that domain then the user must be an employee user.  Try changing to an email address that is not using your account domain and see if that works (or try creating an employee user).

Link to comment
  • 0
2 hours ago, Robert Horvick said:

Based on the error message, I think the issue might be that you have are attempting to create an user whose email address domain matches your account domain (or account employee domain).  If the user email domain matches that domain then the user must be an employee user.  Try changing to an email address that is not using your account domain and see if that works (or try creating an employee user).

Hello, thanks for your answer, I'm sorry, I'm new with "coding" how would I go about creating a employee user?

Link to comment
  • 0

In the ShareFile API a "User" is a client user - this is someone outside of your organization.  An "AccountUser" is an employee - this is someone inside your organization.

Say your account is for your business Mary's Car Sales and your domain is maryscarsales.com.  When you add Mary's account, she is an employee.  Steve at the front desk is an employee.  The folks in sales and finance are too.  One thing all of these employees have in common, and the issue I think you are running into, is that they all have *@maryscarsales.com email addresses.  

Now, say you want to send a contract to a customer to sign.  That customer is not an employee of Mary's Car Sales and has the email address carbuyer@example.com. 

To automate this process, you want to create an application that the finance team member can use which creates the user (using their name and email address) and then sends them a file.  So you create the powershell script you are using as a template.  That should work just fine because you can create a non-employee user that way.

Everything is now working great!

But now you're expanding - you just hired 25 new people and you don't want to have to manually create each new employee account.  You want to use your existing script as the starting point but, as you've discovered, it fails.  It failed because your script is trying to create non-employees (the User type) - but these folks _are_ employees.  How can we tell?  Because they all have the same email address domain as your account domain.

So you need to modify the employee creation script to use the AccountUser type instead of the User type.

The AccountUser type (and the User type) are documented here:

https://api.sharefile.com/docs/resource?name=Users

The AccountUser type has additional information such as whether or not the employee is an administrator, whether they can create folders, and more.  The linked documentation shows some example.

 

The first question you need to ask is what are you trying to do?  Are you trying to create an employee or a non-employee user.  Depending on that answer you should hopefully now have enough information to make changes needed to get this working.
 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...