Copy a folder with Smartsheet API - Java SDK 2.0.5

189 views Asked by At

I am trying to copy a folder with the Smartsheet API 2.0 (Java SDK 2.0.5). Unfortunately the folders and sheets (all sub folders/sheets too) are copied but the sheet data is missing.

I get no errors everything works fine. I tried several variants of the optional include parameters the ".ALL", "null", ...

This is the example code and the used environment:

  • Netbeans IDE 8.2
  • smartsheet-sdk-java-2.0.5.jar (with maven)
// Optional params
EnumSet includes = EnumSet.complementOf(EnumSet.of(FolderCopyInclusion.ALL)); // Copy all fields!
EnumSet skipRemap = EnumSet.noneOf(FolderRemapExclusion.class); // Remap all fields

// Specify destination.
ContainerDestination destination = new ContainerDestination.AddContainerDestinationBuilder()
        .setDestinationType(DestinationType.FOLDER)
        .setDestinationId(targetFolder.getId())
        .setNewName(folder.getName())
        .build();

smartsheet.folderResources().copyFolder(folder.getId(), destination, includes, skipRemap);

What am i doing wrong? Thanks a lot for your help.

1

There are 1 answers

1
Kim Brandl On

Perhaps try changing this line:

EnumSet includes = EnumSet.complementOf(EnumSet.of(FolderCopyInclusion.ALL)); // Copy all fields!

To this instead:

EnumSet includes = EnumSet.of(FolderCopyInclusion.ALL); 

(I'm not a Java expert, but the change I've suggested is consistent with the code example in the Smartsheet API Documentation.)