tableau / TabMigrate

A lightweight tool for moving Tableau content between multiple Tableau Server environments
MIT License
119 stars 59 forks source link

Live Data Source do not get exported with credentials #14

Open nborua opened 7 years ago

nborua commented 7 years ago

Hi,

I am using TabMigrate v1.13 with Tableau 10.2. When I export my Site, the Live Connections do not get exported with the User ID and Password. I have checked and my Data Sources have Authentication as 'Embedded in Connection'. I also found that the DS xml that gets created, does not have these details. As a result, when I am Uploading from file system to site, these Data Sources are uploaded without the connection details and hence the Views/Workbooks using these DS do not get uploaded. Please let us know what is the solution for this. Thanks

kaleaht commented 7 years ago

Is there any solution for this? If I am moving live connection tds files TabMigrate does not work?

jb062695 commented 7 years ago

Is there a solution to this yet?

Zee-Zee commented 6 years ago

Tableau data sources don't get downloaded with user credentials embedded into them for security reason. Hence you'll have to embed the credentials before you import site contents by creating an xml file to hold database credentials. The file is included in the _SampleFiles directory with the name CredentialExample.xml. It has the following structure: `

` You need to specify the path to this file in the available field on form when using 'upload from file system into site' option. Hope this helps.

karthikeya0204 commented 6 years ago

Hi

If you are using Tab migrate project to publish workbook automatically via c# code , pass the credentials in FinalizePublish method. Code snippet will be as follows.

private SiteWorkbook FinalizePublish( string uploadSessionId, string publishedContentName, string publishedContentType, string projectId, CredentialManager.Credential dbCredentials) { var sb = new StringBuilder();

    //Build the XML part of the MIME message we will post up to server
    var xmlSettings = new XmlWriterSettings();
    xmlSettings.OmitXmlDeclaration = true;
    var xmlWriter = XmlWriter.Create(sb, xmlSettings);
    xmlWriter.WriteStartElement("tsRequest");
    xmlWriter.WriteStartElement("workbook");
    xmlWriter.WriteAttributeString("name", publishedContentName);
    xmlWriter.WriteAttributeString("showTabs", "true");
    //If we have an associated database credential, write it out
    if (dbCredentials != null)
    {
        CredentialXmlHelper.WriteCredential(
            xmlWriter,
            dbCredentials);
    }

    xmlWriter.WriteStartElement("project"); //<project>
    xmlWriter.WriteAttributeString("id", projectId);
    xmlWriter.WriteEndElement();            //</project>
    xmlWriter.WriteEndElement(); // </workbook>
    //Currently not supporting <connectionCredentials>
    xmlWriter.WriteEndElement(); // </tsRequest>
    xmlWriter.Close();
    //_daoengagement.SaveServiceLog("Optix Insights Payload : "+sb.ToString(),"",0);
    var xmlText = sb.ToString(); //Get the XML text out

    //Generate the MIME message and pack the XML into it
    var mimeGenerator = new MimeWriterXml(xmlText);

    //Create a web request to POST the MIME message to server to finalize the publish
    var urlFinalizeUpload = _onlineUrls.Url_FinalizeWorkbookPublish(_onlineSession, uploadSessionId, publishedContentType);

    //NOTE: The publish finalization step can take several minutes, because server needs to unpack the uploaded ZIP and file it away.
    //      For this reason, we pass in a long timeout
    var webRequest = this.CreateAndSendMimeLoggedInRequest(urlFinalizeUpload, "POST", mimeGenerator, TableauServerWebClient.DefaultLongRequestTimeOutMs);

    var response = GetWebReponseLogErrors(webRequest, "finalize workbook publish");
    using (response)
    {
        var xmlDoc = GetWebResponseAsXml(response);

        //Get all the workbook nodes
        var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline");
        var workbookXml = xmlDoc.SelectSingleNode("//iwsOnline:workbook", nsManager);

        try
        {
            return new SiteWorkbook(workbookXml);
        }
        catch (Exception parseXml)
        {
            StatusLog.AddError("Workbook upload, error parsing XML resposne " + parseXml.Message + "\r\n" + workbookXml.InnerXml);
            return null;
        }
    }
}
rain-ha commented 6 years ago

Hi, i tried to update _SampleFiles directory with the name CredentialExample.xml but it does not work. Is there any step I missed? What is the contentProjectName? The sample file i found it in folder TabMigrate-1.13\TabRESTMigrate_SampleFiles

I am using Tableau 10.5.2 and i have subproject. so my structure is as below. Main Project ---> Project 1 --->Data Sources

Can anyone help me on this?