public void TestAttachmentResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); long sheetId = CreateSheet(smartsheet); long discussionId = AttachFileAndUrlToComment(smartsheet, sheetId); ListDiscussionAttachments(smartsheet, sheetId, discussionId); long rowId = AttachFileAndUrlToRow(smartsheet, sheetId); ListRowAttachments(smartsheet, sheetId, rowId); long attachmentId = AttachFileAndUrlToSheet(smartsheet, sheetId); GetAttachment(smartsheet, sheetId, attachmentId); AttachNewVersion(smartsheet, sheetId, attachmentId); ListAttachmentVersions(smartsheet, sheetId, attachmentId); DeleteAttachment(smartsheet, sheetId, attachmentId); smartsheet.SheetResources.DeleteSheet(sheetId); }
public static Sheet InitializeSheet() { SmartsheetClient smartsheet = new SmartsheetBuilder() .SetAccessToken(Secrets.SmartsheetKey) .Build(); Sheet sheet = smartsheet.SheetResources.GetSheet( Secrets.AssetSheetId, // sheetId null, // IEnumerable<SheetLevelInclusion> includes null, // IEnumerable<SheetLevelExclusion> excludes null, // IEnumerable<long> rowIds null, // IEnumerable<int> rowNumbers null, // IEnumerable<long> columnIds null, // Nullable<long> pageSize null // Nullable<long> page ); // Instantiate a new column map every time the Sheet is initialized ColumnMap = new Dictionary <string, long>(); // Build column map for later reference foreach (Column column in sheet.Columns) { ColumnMap.Add(column.Title, (long)column.Id); } return(sheet); }
private static void UseTokenResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); try { smartsheet.TokenResources.GetAccessToken(); Assert.Fail(); } catch { } try { smartsheet.TokenResources.RefreshAccessToken(); Assert.Fail(); } catch { } smartsheet.TokenResources.RevokeAccessToken(); try { smartsheet.SheetResources.ListSheets(null, null); Assert.Fail(); } catch { } }
public void TestSheetMoveResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); // Before // Sheet // Folder // After // // Folder-----SheetCopy long folderId = CreateFolderInHome(smartsheet, "Folder1"); long sheetId = CreateSheet(smartsheet); ContainerDestination destination = new ContainerDestination { DestinationId = folderId, DestinationType = DestinationType.FOLDER, //NewName = "hello" }; Sheet newMovedSheet = smartsheet.SheetResources.MoveSheet(sheetId, destination); Assert.IsTrue(newMovedSheet.Name == "new sheet"); long movedSheetId = newMovedSheet.Id.Value; Sheet movedSheet = smartsheet.SheetResources.GetSheet(movedSheetId, null, null, null, null, null, null, null); Assert.IsTrue(movedSheet.Name == "new sheet"); //Deleting the folder will also delete the sheet. DeleteFolders(smartsheet, folderId); }
static void Main(string[] args) { // Initialize client SmartsheetClient ss = new SmartsheetBuilder() // .SetAccessToken("feo3t736fc2lpansdevs4a1as") // TODO: Set your API access in environment variable SMARTSHEET_ACCESS_TOKEN or else here .Build(); // List all sheets PaginatedResult <Sheet> sheets = ss.SheetResources.ListSheets(null, null, null); Console.WriteLine("Found " + sheets.TotalCount + " sheets"); if (sheets.TotalCount > 0) { long sheetId = (long)sheets.Data[0].Id; // Default first sheet // sheetId = 5670346721388420L; // TODO: Uncomment if you wish to read a specific sheet Console.WriteLine("Loading sheet id: " + sheetId); // Load the entire sheet var sheet = ss.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null); Console.WriteLine("Loaded " + sheet.Rows.Count + " rows from sheet: " + sheet.Name); // Display the first 5 rows foreach (Row row in sheet.Rows.Take(5)) { dumpRow(row, sheet.Columns); } } Console.WriteLine("Done (Hit enter)"); // Keep console window open Console.ReadLine(); }
private async void btnSubmitToken_Click(object sender, EventArgs e) { Token = txtAccessToken.Text; // Build the client SmartsheetClient client = null; try { // Build the client in a thread to avoid UI Lock await Task.Factory.StartNew(() => client = new SmartsheetBuilder().SetAccessToken(Token).Build()); } catch (Exception ex) { MessageBox.Show(ex.Message); } // If the client has been successfully created if (client != null) { // Create a client form and show it ClientForm clientForm = new ClientForm(client, this); clientForm.Show(); // Hide the login form this.Visible = false; } }
public void TestSheetCopyResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); // Before // Sheet // Folder // After // Sheet // Folder-----SheetCopy long folderId = CreateFolderInHome(smartsheet, "Folder1"); long sheetId = CreateSheet(smartsheet); ContainerDestination destination = new ContainerDestination { DestinationId = folderId, DestinationType = DestinationType.FOLDER, NewName = "SheetCopy" }; Sheet newCopiedSheet = smartsheet.SheetResources.CopySheet(sheetId, destination, new SheetCopyInclusion[] { SheetCopyInclusion.ALL }); Assert.IsTrue(newCopiedSheet.Name == "SheetCopy"); long copiedSheetId = newCopiedSheet.Id.Value; Sheet copiedSheet = smartsheet.SheetResources.GetSheet(copiedSheetId, null, null, null, null, null, null, null); Assert.IsTrue(copiedSheet.Name == "SheetCopy"); DeleteFolders(smartsheet, folderId); smartsheet.SheetResources.DeleteSheet(sheetId); }
public void TestAttachmentResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); long sheetId = CreateSheet(smartsheet); long discussionId = AttachFileAndUrlToComment(smartsheet, sheetId); ListDiscussionAttachments(smartsheet, sheetId, discussionId); long rowId = AttachFileAndUrlToRow(smartsheet, sheetId); ListRowAttachments(smartsheet, sheetId, rowId); long attachmentId = AttachFileAndUrlToSheet(smartsheet, sheetId); GetAttachment(smartsheet, sheetId, attachmentId); AttachNewVersion(smartsheet, sheetId, attachmentId); ListAttachmentVersions(smartsheet, sheetId, attachmentId); DeleteAttachment(smartsheet, sheetId, attachmentId); smartsheet.SheetResources.DeleteSheet(sheetId); }
private static void UseTokenResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); try { smartsheet.TokenResources.GetAccessToken(); Assert.Fail(); } catch { } try { smartsheet.TokenResources.RefreshAccessToken(); Assert.Fail(); } catch { } smartsheet.TokenResources.RevokeAccessToken(); try { smartsheet.SheetResources.ListSheets(null, null); Assert.Fail(); } catch { } }
public void TestWorkspaceCopyResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); // Before // Workspace1 // Folder2 // After // Workspace1 // Folder2-----Workspace1Copy Workspace workspace = smartsheet.WorkspaceResources.CreateWorkspace(new Workspace.CreateWorkspaceBuilder("Workspace1").Build()); long workspaceId = workspace.Id.Value; ContainerDestination destination = new ContainerDestination { NewName = "Workspace1Copy" }; Workspace newCopiedWorkspace = smartsheet.WorkspaceResources.CopyWorkspace(workspaceId, destination, new WorkspaceCopyInclusion[] { WorkspaceCopyInclusion.ALL }, new WorkspaceRemapExclusion[] { WorkspaceRemapExclusion.CELL_LINKS }); Assert.IsTrue(newCopiedWorkspace.Name == "Workspace1Copy"); long copiedWorkspaceId = newCopiedWorkspace.Id.Value; Workspace copiedWorkspace = smartsheet.WorkspaceResources.GetWorkspace(copiedWorkspaceId, null, null); Assert.IsTrue(copiedWorkspace.Name == "Workspace1Copy"); smartsheet.WorkspaceResources.DeleteWorkspace(workspaceId); smartsheet.WorkspaceResources.DeleteWorkspace(copiedWorkspaceId); }
public void TestFolderCopyResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); // Before // Folder1-----SubFolder1 // Folder2 // After // Folder1-----SubFolder1 // Folder2-----SubFolder1Copy long createdFolderInHomeId1 = CreateFolderInHome(smartsheet, "Folder1"); long createdFolderInHomeId2 = CreateFolderInHome(smartsheet, "Folder2"); long createdFolderInFolderId = CreateFolderInFolder(smartsheet, createdFolderInHomeId1, "SubFolder1"); ContainerDestination destination = new ContainerDestination { DestinationId = createdFolderInHomeId2, DestinationType = DestinationType.FOLDER, NewName = "SubFolder1Copy" }; Folder newCopiedFolder = smartsheet.FolderResources.CopyFolder(createdFolderInFolderId, destination, new FolderCopyInclusion[] { FolderCopyInclusion.ALL }, new FolderRemapExclusion[] { FolderRemapExclusion.CELL_LINKS }); Assert.IsTrue(newCopiedFolder.Name == "SubFolder1Copy"); long copiedFolderId = newCopiedFolder.Id.Value; Folder copiedFolder = smartsheet.FolderResources.GetFolder(copiedFolderId, null); Assert.IsTrue(copiedFolder.Name == "SubFolder1Copy"); DeleteFolders(smartsheet, createdFolderInHomeId1, createdFolderInHomeId2); }
public void TestContactResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); PaginatedResult <Contact> contactResults = smartsheet.ContactResources.ListContacts(null); Assert.IsTrue(contactResults.TotalCount >= 0); }
public void TestHomeResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); Home home = smartsheet.HomeResources.GetHome(new HomeInclusion[] { HomeInclusion.SOURCE }); Assert.IsTrue(home != null); }
public ActionResult Index() { List <ErrorReport> model = new List <ErrorReport>(); SmartsheetClient sheetclient = new SmartsheetBuilder().SetAccessToken(token).Build(); PaginatedResult <Column> cols = sheetclient.SheetResources.ColumnResources.ListColumns(sheetid, null, null); Sheet sheet = sheetclient.SheetResources.GetSheet(sheetid, null, null, null, null, null, null, null); //Gets the sheet id foreach (Row r in sheet.Rows) { ErrorReport newreport = new ErrorReport(); try { newreport.ID = int.Parse(r.Cells[0].Value.ToString()); } catch { newreport.ID = 0; } newreport.Date = DateTime.Parse(r.Cells[1].Value.ToString()); newreport.UserName = r.Cells[2].Value.ToString(); try { newreport.ErrorMessage = r.Cells[3].Value.ToString(); } catch { newreport.ErrorMessage = ""; } try { newreport.Enhancement = r.Cells[4].Value.ToString(); } catch { newreport.Enhancement = ""; } try { newreport.Description = r.Cells[5].Value.ToString(); } catch { newreport.Description = ""; } newreport.Category = r.Cells[6].Value.ToString(); try { newreport.Status = r.Cells[7].Value.ToString(); } catch { newreport.Status = ""; } newreport.Modified = DateTime.Parse(r.Cells[8].Value.ToString()); model.Add(newreport); } return(View(model)); }
private static void UseOAuthFlow() { OAuthFlow oauth = new OAuthFlowBuilder() .SetClientId("1tziajulcsbqsswgy37") .SetClientSecret("sxouqll7zluvzmact3") .SetRedirectURL("https://www.google.com") .Build(); string url = oauth.NewAuthorizationURL ( new Smartsheet.Api.OAuth.AccessScope[] { Smartsheet.Api.OAuth.AccessScope.READ_SHEETS, Smartsheet.Api.OAuth.AccessScope.WRITE_SHEETS, Smartsheet.Api.OAuth.AccessScope.SHARE_SHEETS, Smartsheet.Api.OAuth.AccessScope.DELETE_SHEETS, Smartsheet.Api.OAuth.AccessScope.CREATE_SHEETS, Smartsheet.Api.OAuth.AccessScope.READ_USERS, Smartsheet.Api.OAuth.AccessScope.ADMIN_USERS, Smartsheet.Api.OAuth.AccessScope.ADMIN_SHEETS, Smartsheet.Api.OAuth.AccessScope.ADMIN_WORKSPACES, }, "key=Test" ); // Take the user to the following URL Debug.WriteLine(url); // After the user accepts or declines the authorization they are taken to the redirect URL. The URL of the page // the user is taken to can be used to generate an authorization RequestResult object. string authorizationResponseURL = "https://www.google.com/?code=yn8kl1kvruh31uj&expires_in=599957&state=key%3DTest"; // On this page pass in the full URL of the page to create an authorizationResult object AuthorizationResult authResult = oauth.ExtractAuthorizationResult(authorizationResponseURL); // Get the token from the authorization result Token token = oauth.ObtainNewToken(authResult); Assert.IsTrue(token.AccessToken == "ACCESS_TOKEN"); Token tokenRefreshed = oauth.RefreshToken(token); Assert.IsTrue(token.AccessToken != "ACCESS_TOKEN"); oauth.RevokeToken(token); SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(token.AccessToken).Build(); try { smartsheet.SheetResources.ListSheets(null, null); Assert.Fail(); } catch { } }
public void TestContactResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); PaginatedResult <Contact> contactResults = smartsheet.ContactResources.ListContacts(null); Assert.IsTrue(contactResults.TotalCount >= 0); }
private static SmartsheetClient GetClient() { // Initialize client SmartsheetClient client = new SmartsheetBuilder() // TODO: Set your API access in environment variable SMARTSHEET_ACCESS_TOKEN or else here .SetAccessToken(ConfigurationManager.AppSettings["SmartsheetApiKey"]) .Build(); return(client); }
public static SmartsheetClient SetupClient(string apiScenario) { SmartsheetClient ss = new SmartsheetBuilder() .SetBaseURI("http://localhost:8082/") .SetAccessToken("aaaaaaaaaaaaaaaaaaaaaaaaaa") .SetSDKAPITestScenario(apiScenario) .Build(); return(ss); }
public void TestHomeResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); Home home = smartsheet.HomeResources.GetHome(new HomeInclusion[] { HomeInclusion.SOURCE }); Assert.IsTrue(home != null); }
public void TestServerInfoResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); ServerInfo info = smartsheet.ServerInfoResources.GetServerInfo(); Assert.IsTrue(info.FeatureInfo != null); Assert.IsTrue(info.Formats != null); Assert.IsTrue(info.SupportedLocales != null); }
public static SmartsheetClient SetupClient(string apiScenario) { TestHttpClient testHttpClient = new TestHttpClient(apiScenario); SmartsheetClient ss = new SmartsheetBuilder() .SetBaseURI("http://localhost:8082/") .SetAccessToken("aaaaaaaaaaaaaaaaaaaaaaaaaa") .SetHttpClient(testHttpClient) .Build(); return(ss); }
public void TestServerInfoResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); ServerInfo info = smartsheet.ServerInfoResources.GetServerInfo(); Assert.IsTrue(info.FeatureInfo != null); Assert.IsTrue(info.Formats != null); Assert.IsTrue(info.SupportedLocales != null); }
public void TestColumnResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); long sheetId = CreateSheet(smartsheet); AddColumns(smartsheet, sheetId); long columnId = ListColumns(smartsheet, sheetId); UpdateColumn(smartsheet, sheetId, columnId); DeleteAndGetColumn(smartsheet, sheetId, columnId); }
public void TestSheetResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); long sheetId = CreateSheet(smartsheet); SendSheet(smartsheet, sheetId); UpdateSheet(smartsheet, sheetId); UpdatePublishSheetStatus(smartsheet, sheetId); GetSheetAsPDF(smartsheet, sheetId); SortSheet(smartsheet, sheetId); DeleteSheet(smartsheet, sheetId); }
public void TestFolderResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); long createdFolderInHomeId = CreateFolderInHome(smartsheet); long createdFolderInFolderId = CreateFolderInFolder(smartsheet, createdFolderInHomeId); ListFoldersInFolder(smartsheet, createdFolderInHomeId, createdFolderInFolderId); UpdateFolderInFolder(smartsheet, createdFolderInFolderId); GetFolderInHome(smartsheet, createdFolderInHomeId, createdFolderInFolderId); DeleteFolders(smartsheet, createdFolderInHomeId, createdFolderInFolderId); }
public void TestSheetResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); long sheetId = CreateSheet(smartsheet); SendSheet(smartsheet, sheetId); UpdateSheet(smartsheet, sheetId); UpdatePublishSheetStatus(smartsheet, sheetId); GetSheetAsPDF(smartsheet, sheetId); DeleteSheet(smartsheet, sheetId); }
public void TestWorkspaceResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); long workspaceId = CreateWorkspace(smartsheet); UpdateWorkspace(smartsheet, workspaceId); GetWorkspace(smartsheet, workspaceId); ListWorkspaces(smartsheet, workspaceId); DeleteWorkspace(smartsheet, workspaceId); }
public void TestColumnResources() { SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build(); long sheetId = CreateSheet(smartsheet); AddColumns(smartsheet, sheetId); long columnId = ListColumns(smartsheet, sheetId); UpdateColumn(smartsheet, sheetId, columnId); DeleteAndGetColumn(smartsheet, sheetId, columnId); smartsheet.SheetResources.DeleteSheet(sheetId); }
static Dictionary <string, long> columnMap = new Dictionary <string, long>(); // Map from friendly column name to column Id static void Main(string[] args) { // Get API access token from App.config file or environment string accessToken = ConfigurationManager.AppSettings["AccessToken"]; if (string.IsNullOrEmpty(accessToken)) { accessToken = Environment.GetEnvironmentVariable("SMARTSHEET_ACCESS_TOKEN"); } if (string.IsNullOrEmpty(accessToken)) { throw new Exception("Must set API access token in App.conf file"); } // Get sheet Id from App.config file string sheetIdString = ConfigurationManager.AppSettings["SheetId"]; long sheetId = long.Parse(sheetIdString); // Initialize client SmartsheetClient ss = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); // Load the entire sheet Sheet sheet = ss.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null); Console.WriteLine("Loaded " + sheet.Rows.Count + " rows from sheet: " + sheet.Name); // Build column map for later reference foreach (Column column in sheet.Columns) { columnMap.Add(column.Title, (long)column.Id); } // Accumulate rows needing update here List <Row> rowsToUpdate = new List <Row>(); foreach (Row row in sheet.Rows) { Row rowToUpdate = evaluateRowAndBuildUpdates(row); if (rowToUpdate != null) { rowsToUpdate.Add(rowToUpdate); } } // Finally, write all updated cells back to Smartsheet Console.WriteLine("Writing " + rowsToUpdate.Count + " rows back to sheet id " + sheet.Id); ss.SheetResources.RowResources.UpdateRows(sheetId, rowsToUpdate); Console.WriteLine("Done (Hit enter)"); Console.ReadLine(); }
public void TestFolderResources() { string accessToken = ConfigurationManager.AppSettings["accessToken"]; SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(accessToken).Build(); long createdFolderInHomeId = CreateFolderInHome(smartsheet); long createdFolderInFolderId = CreateFolderInFolder(smartsheet, createdFolderInHomeId); ListFoldersInFolder(smartsheet, createdFolderInHomeId, createdFolderInFolderId); UpdateFolderInFolder(smartsheet, createdFolderInFolderId); GetFolderInHome(smartsheet, createdFolderInHomeId, createdFolderInFolderId); DeleteFolders(smartsheet, createdFolderInHomeId, createdFolderInFolderId); }