I have the code below in my Sandbox environment. I'm test running it in Developer Console. My sandbox environment is connected to my Box.com account. What I'm attempting to do is create a new folder (and sub-folders) in Box.com by executing the code below. The code executes successfully in Developer Console, but it doesn't create a folder in Box. The code seems relatively simple and straight-forward, but I get no new folder in Box, and I get 'Null' for all values.
======= START CODE EXECUTED VIA DEVELOPER CONSOLE > ANONYMOUS BLOCK =====
//Instantiate the Toolkit object box.Toolkit boxToolkit = new box.Toolkit(); //Create a folder and associate it with an account Id accountId = '001j000000FBozz'; String accountFolderId = boxToolkit.createFolderForRecordId(accountId, null, true); system.debug('new item folder id: ' + accountFolderId); //Create two sub-folders in the newly created account folder String legalFolderId = boxToolkit.createFolder('Legal Documents', accountFolderId, null); system.debug('Legal Folder id: ' + legalFolderId); String pictureFolderId = boxToolkit.createFolder('Pictures', accountFolderId, null); system.debug('Picture Folder id: ' + pictureFolderId); //Collaborate the current user on the account folder //Note that we're sending false for the optCreateFolder param // that shouldn't actually matter since the folder(s) already exists Id userId = UserInfo.getUserId(); box.Toolkit.CollaborationType collabType = box.Toolkit.CollaborationType.EDITOR; String collabId = boxToolkit.createCollaborationOnRecord(userId, accountId, collabType, false); system.debug('new collaboration id: ' + collabId); //ALWAYS call this method when finished. //Since salesforce doesn't allow http callouts after dml operations, // we need to commit the pending database inserts/updates or we will // lose the associations created boxToolkit.commitChanges();
============= END CODE ==================