I am building an app that uses box, and I want to add a collaboration on my folder for a given user.
Looking at box doc (https://github.com/box/box-node-sdk/blob/master/docs/collaborations.md) I am doing the following :
const assignUserToFolder = function(appUserId) {
//Get App auth client
const boxAdminClient =
BoxSdk.getAppAuthClient('enterprise', process.env.BOX_ENTERPRISE_ID);
console.log(`assign user ${appUserId} to folder ${process.env.BOX_FOLDER_ID}`);
boxAdminClient.collaborations.createWithUserID(
appUserId,
process.env.BOX_FOLDER_ID,
boxAdminClient.collaborationRoles.EDITOR, (
function (error, boxResponse) {
if (error) {
console.log(`error ${error}`);
}
}));
};I have verified that the box client is correct and appUserId and the folderId have correct values.
I have also tested using the API (https://developer.box.com/reference#add-a-collaboration) directly and I was able to update and set the correct role for my folder.
Though, I would like to run it from my node app and use the node sdk directly.
Does anyone know why this would not work ?