findUsers method

Future<List<User>> findUsers({
  1. String? query,
  2. String? username,
  3. String? accountId,
  4. int? startAt,
  5. int? maxResults,
  6. String? property,
})

Returns a list of users that match the search string and property.

This operation first applies a filter to match the search string and property, and then takes the filtered users in the range defined by startAt and maxResults, up to the thousandth user. To get all the users who match the search string and property, use Get all users and filter the records in your code.

This operation can be accessed anonymously.

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.

Permissions required: Browse users and groups global permission. Anonymous calls or calls by users without the required permission return empty search results.

Implementation

Future<List<User>> findUsers(
    {String? query,
    String? username,
    String? accountId,
    int? startAt,
    int? maxResults,
    String? property}) async {
  return (await _client.send(
    'get',
    'rest/api/3/user/search',
    queryParameters: {
      if (query != null) 'query': query,
      if (username != null) 'username': username,
      if (accountId != null) 'accountId': accountId,
      if (startAt != null) 'startAt': '$startAt',
      if (maxResults != null) 'maxResults': '$maxResults',
      if (property != null) 'property': property,
    },
  ) as List<Object?>)
      .map((i) => User.fromJson(i as Map<String, Object?>? ?? const {}))
      .toList();
}