2

I am trying to use the Smartsheet API 2.0 in java to copy an existing sheet to a new sheet in an existing folder. I would like to include the data, attachments and discussions. I have tried setting the include parameter to SheetCopyInclusion.ALL as well as SheetCopyInclusion.DATA, SheetCopyInclusion.ATTACHMENTS and SheetCopyInclusion.DISCUSSIONS. The sheet copies, but never the data.

Here is my code:

Token token = new Token();
token.setAccessToken( accessToken );

Smartsheet smartsheet = new SmartsheetBuilder().setAccessToken( token.getAccessToken() ).build();

ContainerDestination myCopiedSheet = new ContainerDestination.AddContainerDestinationBuilder()
    .setDestinationType( DestinationType.FOLDER )
    .setDestinationId( backupFolderId )
    .setNewName( "My Copied Sheet" )
    .build();

smartsheet.sheetResources().copySheet( sourceSheetId, myCopiedSheet, EnumSet.of( SheetCopyInclusion.ALL ));

Any assistance on why the data is not being copied would be appreciated. Thank you.

T R
  • 23
  • 2

1 Answers1

1

T R, this is an issue with the SheetCopyInclusion enumeration. Rather than 'return super.toString();' the toString function in SheetCopyInclusion should return the inclusion String. If you are building the SDK from source, you can modify toString in SheetCopyInclusion.java:

@Override
public String toString() {
    return inclusion;
    //return super.toString();
}

I will submit a pull request to the JAVA SDK with a fix.

timwells
  • 341
  • 1
  • 4
  • Thanks @timwells! I am using the Smartsheet JAR file and would rather not modify the source if I don't have to. Is there any other option? I'm thinking about doing a Java command line execute of the curl command to copy a sheet. – T R Jun 16 '16 at 12:16