Url_UpdateDatasource() public method

URL for updating datasource metadata (e.g. owner id)
public Url_UpdateDatasource ( TableauServerSignIn, session, string datasourceId ) : string
session TableauServerSignIn,
datasourceId string
return string
    private SiteDatasource ChangeContentOwner(string datasourceId, string newOwnerId)
    {
        AppDiagnostics.Assert(!string.IsNullOrWhiteSpace(datasourceId), "missing datasource id");
        AppDiagnostics.Assert(!string.IsNullOrWhiteSpace(newOwnerId), "missing owner id");

        //ref: https://onlinehelp.tableau.com/current/api/rest_api/en-us/help.htm#REST/rest_api_ref.htm#Update_Datasource%3FTocPath%3DAPI%2520Reference%7C_____76
        var sb        = new StringBuilder();
        var xmlWriter = XmlWriter.Create(sb, XmlHelper.XmlSettingsForWebRequests);

        xmlWriter.WriteStartElement("tsRequest");
        xmlWriter.WriteStartElement("datasource");
        xmlWriter.WriteStartElement("owner");
        xmlWriter.WriteAttributeString("id", newOwnerId);
        xmlWriter.WriteEndElement(); //</owner>
        xmlWriter.WriteEndElement(); //</datasource>
        xmlWriter.WriteEndElement(); // </tsRequest>
        xmlWriter.Close();

        var xmlText = sb.ToString(); //Get the XML text out

        //Create a web request
        var urlUpdateDatasource = _onlineUrls.Url_UpdateDatasource(_onlineSession, datasourceId);
        var webRequest          = this.CreateLoggedInWebRequest(urlUpdateDatasource, "PUT");

        TableauServerRequestBase.SendPutContents(webRequest, xmlText);

        //Get the response
        var response = GetWebReponseLogErrors(webRequest, "update datasource (change owner)");

        using (response)
        {
            var xmlDoc = GetWebResponseAsXml(response);


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

            try
            {
                return(new SiteDatasource(xNodeDs));
            }
            catch (Exception parseXml)
            {
                StatusLog.AddError("Change datasource owner, error parsing XML response " + parseXml.Message + "\r\n" + xNodeDs.InnerXml);
                return(null);
            }
        }
    }