TableauServerUrls.Url_GroupsList C# (CSharp) Method

Url_GroupsList() public method

URL for the Groups list
public Url_GroupsList ( TableauServerSignIn, session, int pageSize, int pageNumber = 1 ) : string
session TableauServerSignIn,
pageSize int
pageNumber int
return string
    public string Url_GroupsList(TableauServerSignIn session, int pageSize, int pageNumber = 1)
    {
        string workingText = _urlListGroupsTemplate;
        workingText = workingText.Replace("{{iwsSiteId}}", session.SiteId);
        workingText = workingText.Replace("{{iwsPageSize}}", pageSize.ToString());
        workingText = workingText.Replace("{{iwsPageNumber}}", pageNumber.ToString());
        ValidateTemplateReplaceComplete(workingText);

        return workingText;
    }

Usage Example

    /// <summary>
    /// Get a page's worth of Groups
    /// </summary>
    /// <param name="onlineGroups"></param>
    /// <param name="pageToRequest">Page # we are requesting (1 based)</param>
    /// <param name="totalNumberPages">Total # of pages of data that Server can return us</param>
    private void ExecuteRequest_ForPage(
        List <SiteGroup> onlineGroups,
        int pageToRequest,
        bool downloadMemberList,
        out int totalNumberPages)
    {
        int pageSize = _onlineUrls.PageSize;
        //Create a web request, in including the users logged-in auth information in the request headers
        var urlQuery = _onlineUrls.Url_GroupsList(_onlineSession, pageSize, pageToRequest);

        _onlineSession.StatusLog.AddStatus("Web request: " + urlQuery, -10);
        XmlDocument xmlDoc = ResourceSafe_PerformWebRequest_GetXmlDocument(urlQuery, "get groups list");

        //Get all the group nodes
        var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline");
        var groups    = xmlDoc.SelectNodes("//iwsOnline:group", nsManager);

        //Get information for each of the data sources
        foreach (XmlNode itemXml in groups)
        {
            SiteGroup thisGroup = null;
            try
            {
                thisGroup = new SiteGroup(
                    itemXml,
                    null);   //We'll get and add the list of users later (see below)
                onlineGroups.Add(thisGroup);
                SanityCheckGroup(thisGroup, itemXml);
            }
            catch (Exception exGetGroup)
            {
                AppDiagnostics.Assert(false, "Group parse error");
                _onlineSession.StatusLog.AddError("Error parsing group: " + itemXml.OuterXml + ", " + exGetGroup.Message);
            }


            //==============================================================
            //Get the set of users in the group
            //==============================================================
            if ((thisGroup != null) && (downloadMemberList))
            {
                try
                {
                    var downloadUsersInGroup = new DownloadUsersListInGroup(
                        _onlineSession,
                        thisGroup.Id);
                    downloadUsersInGroup.ExecuteRequest();
                    thisGroup.AddUsers(downloadUsersInGroup.Users);
                }
                catch (Exception exGetUsers)
                {
                    _onlineSession.StatusLog.AddError("Error parsing group's users: " + exGetUsers.Message);
                }
            }
        } //end: foreach

        //-------------------------------------------------------------------
        //Get the updated page-count
        //-------------------------------------------------------------------
        totalNumberPages = DownloadPaginationHelper.GetNumberOfPagesFromPagination(
            xmlDoc.SelectSingleNode("//iwsOnline:pagination", nsManager),
            pageSize);
    }