private void _UpdateUser(string userID, string siteRole)
        {
            var sb          = new StringBuilder();
            var xmlSettings = new XmlWriterSettings();

            xmlSettings.OmitXmlDeclaration = true;
            var xmlWriter = XmlWriter.Create(sb, xmlSettings);

            xmlWriter.WriteStartElement("tsRequest");
            xmlWriter.WriteStartElement("user");
            xmlWriter.WriteAttributeString("siteRole", siteRole);
            xmlWriter.WriteEndElement(); //</user>
            xmlWriter.WriteEndElement(); // </tsRequest>
            xmlWriter.Close();

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

            //Generate the MIME message
            //var mimeGenerator = new OnlineMimeXmlPayload(xmlText);

            //Create a web request
            var urlUpdateUser = _onlineUrls.Url_UpdateUser(OnlineSession, userID);
            var webRequest    = CreateLoggedInWebRequest(urlUpdateUser, "PUT");

            SendRequestContents(webRequest, xmlText, "PUT");

            //Get the response
            var response = GetWebResponseLogErrors(webRequest, "update user");

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


                //Get all the workbook nodes
                var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline");
                var xNodeUser = xmlDoc.SelectSingleNode("//iwsOnline:user", nsManager);
            }
        }
Esempio n. 2
0
        private void _UpdateUser(string userId, string fullName, string email, string password)
        {
            //ref: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_usersgroups.htm#update_user

            var sb          = new StringBuilder();
            var xmlSettings = new XmlWriterSettings();

            xmlSettings.OmitXmlDeclaration = true;
            var xmlWriter = XmlWriter.Create(sb, xmlSettings);

            xmlWriter.WriteStartElement("tsRequest");
            xmlWriter.WriteStartElement("user");
            xmlWriter.WriteAttributeString("fullName", fullName);
            xmlWriter.WriteAttributeString("email", email);
            xmlWriter.WriteAttributeString("password", password);
            xmlWriter.WriteEndElement(); //</user>
            xmlWriter.WriteEndElement(); //</tsRequest>
            xmlWriter.Close();

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

            //Create a web request
            var urlUpdateUser = _onlineUrls.Url_UpdateUser(OnlineSession, userId);
            var webRequest    = CreateLoggedInWebRequest(urlUpdateUser, "PUT");

            SendRequestContents(webRequest, xmlText, "PUT");

            //Get the response
            var response = GetWebResponseLogErrors(webRequest, "update user");

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

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