protected PublishedWorkbookResult PublishWorkbook(RestApiRequestor requestor, string pluginName, string workbookPath, bool overwriteExistingWorkbook = true) { var workbookFilename = Path.GetFileName(workbookPath); // Tag the workbook with the name of the plugin that generated it. logsharkRequest.WorkbookTags.Add(pluginName); Log.InfoFormat("Publishing workbook '{0}' to {1}..", workbookFilename, tableauConnectionInfo.ToUri()); var publishWorkbookRequest = new PublishWorkbookRequest(workbookPath) { PluginName = pluginName, SiteId = siteId, SiteName = tableauConnectionInfo.Site, ProjectId = projectId, ProjectName = logsharkRequest.ProjectName, DatasourceUserName = postgresConnectionInfo.Username, DatasourcePassword = postgresConnectionInfo.Password, Tags = logsharkRequest.WorkbookTags, OverwriteExistingWorkbook = overwriteExistingWorkbook, ShowSheetsAsTabs = true, publishingTimeoutSeconds = tableauConnectionInfo.PublishingTimeoutSeconds }; PublishedWorkbookResult result = requestor.PublishWorkbookWithEmbeddedCredentials(publishWorkbookRequest); int attemptsMade = 1; while (!result.IsSuccessful && attemptsMade < CoreConstants.WORKBOOK_PUBLISHING_MAX_ATTEMPTS) { Log.WarnFormat("Workbook publishing attempt #{0} failed. Retrying in {1} {2}..", attemptsMade, CoreConstants.WORKBOOK_PUBLISHING_RETRY_DELAY_SEC, "second".Pluralize(CoreConstants.WORKBOOK_PUBLISHING_RETRY_DELAY_SEC)); Thread.Sleep(1000 * CoreConstants.WORKBOOK_PUBLISHING_RETRY_DELAY_SEC); result = requestor.PublishWorkbookWithEmbeddedCredentials(publishWorkbookRequest); attemptsMade++; } if (!result.IsSuccessful) { Log.ErrorFormat("Publishing of workbook '{0}' failed: {1} [{2} {3} made]", workbookFilename, result.ErrorMessage, attemptsMade, "attempt".Pluralize(attemptsMade)); } return(result); }