findUsersForPicker method

Future<FoundUsers> findUsersForPicker({
  1. required String query,
  2. int? maxResults,
  3. bool? showAvatar,
  4. List<String>? exclude,
  5. List<String>? excludeAccountIds,
  6. String? avatarSize,
  7. bool? excludeConnectUsers,
})

Returns a list of users whose attributes match the query term. The returned object includes the html field where the matched query term is highlighted with the HTML strong tag. A list of account IDs can be provided to exclude users from the results.

This operation takes the users in the range defined by maxResults, up to the thousandth user, and then returns only the users from that range that match the query term. This means the operation usually returns fewer users than specified in maxResults. To get all the users who match the query term, use Get all users and filter the records in your code.

Privacy controls are applied to the response based on the users' preferences. This could mean, for example, that the user's email address is hidden. See the Profile visibility overview for more details.

This operation can be accessed anonymously.

Permissions required: Browse users and groups global permission. Anonymous calls and calls by users without the required permission return search results for an exact name match only.

Implementation

Future<FoundUsers> findUsersForPicker(
    {required String query,
    int? maxResults,
    bool? showAvatar,
    List<String>? exclude,
    List<String>? excludeAccountIds,
    String? avatarSize,
    bool? excludeConnectUsers}) async {
  return FoundUsers.fromJson(await _client.send(
    'get',
    'rest/api/3/user/picker',
    queryParameters: {
      'query': query,
      if (maxResults != null) 'maxResults': '$maxResults',
      if (showAvatar != null) 'showAvatar': '$showAvatar',
      if (exclude != null) 'exclude': exclude.map((e) => e).join(','),
      if (excludeAccountIds != null)
        'excludeAccountIds': excludeAccountIds.map((e) => e).join(','),
      if (avatarSize != null) 'avatarSize': avatarSize,
      if (excludeConnectUsers != null)
        'excludeConnectUsers': '$excludeConnectUsers',
    },
  ));
}