0
votes

I'm trying to add an existing user (a user who registered a personal Box account with his email address) to a Box enterprise account using the Box Java SDK (https://github.com/box/box-java-sdk-v2) like so:

String email = "[email protected]";
String name = "John Doe";
BoxUserRequestObject boxUserRequestObject = BoxUserRequestObject.createEnterpriseUserRequestObject(email, name);
BoxUser createdUser = boxClient.getUsersManager().createEnterpriseUser(boxUserRequestObject);

However the SDK fails with an error saying:

com.box.boxjavalibv2.exceptions.BoxServerException: User with the specified login already exists

How do I programmatically invite that user to my enterprise account?

1

1 Answers

1
votes

It's not possible to do this with box-java-sdk-v2, however I did create an issue for adding this functionality to the latest version of our SDK.

You can also check out the REST API documentation for inviting a user to an enterprise. This endpoint will send an email to a user with a personal account, asking them to join your enterprise.

Here's the example cURL call from the docs:

curl https://api.box.com/2.0/invites \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{ "enterprise" : { "id" : "42500" } , "actionable_by" : { "login" : "[email protected]" } }' \
-X POST