Last active
May 9, 2017 21:16
-
-
Save stmcallister/4301f04fa3cf6c446f06889f615ae02a to your computer and use it in GitHub Desktop.
Create Smartsheet UpdateRequest with Java SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a sample for creating an UpdateRequest in Smartsheet | |
private static void createUpdateRequest() throws SmartsheetException { | |
Token token = new Token(); | |
// Generate third party access token in Smartsheet. | |
// To learn how: https://smartsheet-platform.github.io/api-docs/?java#direct-api-access | |
token.setAccessToken("third-party-access-token"); | |
// Use the Smartsheet Builder to create a Smartsheet object | |
Smartsheet smartsheet = new SmartsheetBuilder().setAccessToken(token.getAccessToken()).build(); | |
long sheetId = <sheet_id>; | |
String email = "person_to_update_email_address"; | |
long rowId = <row_id>; | |
String message = "You should update this"; | |
UpdateRequest updateRequest = new UpdateRequest(); | |
Recipient sendToEmail = new RecipientEmail.AddRecipientEmailBuilder().setEmail(email).build(); | |
// Grab the columns from your sheet | |
List<Column> columns = smartsheet.sheetResources().columnResources().listColumns(sheetId, null, null).getData(); | |
List<Long> columnIds = new ArrayList<Long>(); | |
// Gather columnIds into a list to set to the updateRequest object below | |
for (Column column : columns | |
) { | |
columnIds.add(column.getId()); | |
} | |
updateRequest.setSubject("Update Request from Your Friendly Java SDK"); | |
updateRequest.setCcMe(true); | |
updateRequest.setMessage(message); | |
updateRequest.setSendTo(Arrays.asList(sendToEmail)); | |
updateRequest.setRowIds(Arrays.asList(rowId)); | |
updateRequest.setIncludeAttachments(false); | |
updateRequest.setIncludeDiscussions(false); | |
updateRequest.setColumnIds(columnIds); | |
UpdateRequest updateRequestResult = smartsheet.sheetResources().updateRequestResources().createUpdateRequest(sheetId, updateRequest); | |
System.out.println(updateRequestResult.getId()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment