Search Results for

    Show / Hide Table of Contents

    Working with groups

    This article walks you through the process of creating a new group, adding a user to the group, and getting a list of the group's users.

    Getting Started

    You will need the following tools and features:

    1. Knowledge of using API key in FastReport Cloud.

      This article will skip additional information on authentication and authorization.

    2. .NET SDK.

    3. A C# code editor or a text editor such as Visual Studio Code.

    4. Active FastReport Cloud subscription, which has two user slots.

    5. Access to the Internet.

    Note! This guide assumes that you already know how to develop your application in the C# programming language.

    Note! The paragraphs above describe the recommended tools.

    Comment

    Note! It is only possible to add a user to a group if the user exists in the workspace.

    Note! It is only possible to add a user to a group by its identifier.

    Instruction

    1. To create a new group, you need a workspace identifier and a name for the new group.

      To get the workspace identifier, use the method GetSubscriptionsAsync(Nullable<Int32>, Nullable<Int32>, System.Threading.CancellationToken).

      public async Task<string> GetSubscriptionId(HttpClient httpClient)
      {
          ISubscriptionsClient subscriptionsClient = new SubscriptionsClient(httpClient);
      
          SubscriptionsVM subscriptions = 
           await subscriptionsClient.GetSubscriptionsAsync(0, 10);
      
          SubscriptionVM subscription = subscriptions.Subscriptions.First();
      
          return subscription.Id;
      }
      

      In this example, the function requests the first 10 workspaces from the user's list of workspaces, selects the first workspace, and returns its identifier.

      The workspace and the subscription identifiers are the same because one subscription is associated with each workspace.

    2. To create a new group, use the method CreateGroupAsync(CreateGroupVM, System.Threading.CancellationToken).

      public async Task<string> CreateGroup(HttpClient httpClient, 
                                            string subscriptionId, 
                                            string groupName)
      {
          IGroupsClient groupsClient = new GroupsClient(httpClient);
      
          CreateGroupVM viewModel = new CreateGroupVM()
          {
              Name = groupName,
              SubscriptionId = subscriptionId
          };
      
          GroupVM group = await groupsClient.CreateGroupAsync(viewModel);
      
          return group.Id;
      }
      

      In this example, the function creates a new group named groupName for the workspace with the subscriptionId identifier, as a result, the function will return the identifier of the created group.

    3. To add a new user to the group, use the method AddUserToGroupAsync(String, String, System.Threading.CancellationToken).

      public async Task AddUser(HttpClient httpClient, string groupId, string userId)
      {
          IGroupUsersClient groupUsersClient = new GroupUsersClient(httpClient);
      
          await groupUsersClient.AddUserToGroupAsync(groupId, userId);
      }
      

      In this example, the function adds the user with the userId identifier to the group with the groupId identifier.

    4. To get a list of users in the group, use the method GetUsersInGroupAsync(String, Nullable<Int32>, Nullable<Int32>, System.Threading.CancellationToken).

      public async Task<IEnumerable<string>> GetUsers(HttpClient httpClient, string groupId)
      {
          IGroupUsersClient groupUsersClient = new GroupUsersClient(httpClient);
      
          GroupUsersVM users = 
          	await groupUsersClient.GetUsersInGroupAsync(groupId, 0, 10);
      
       return users.Users.Select(m => m.UserId);
      }
      

      In this example, the function requests the first 10 users from the group with the groupId identifier.

    What's next?

    • Help and feedback
    Back to top 2025.2.1 © 1998-2025 Copyright Fast Reports Inc.