8

I'm developing a Java client to interact with Moodle. I want to get all the users registered within a Moodle installation.

I found the webservice function called core_user_get_users which returns a list with users.

When I call the service without any parameters I get a repsonse with a invalid parameter exception.

When I add a criteria parameter (criteria[0][key]=id&criteria[0][value]=some_id) it returns a single user with that specific id.

I can't seem to find what criteria to pass to the function to get the entire list with users registered.

Liam de Haas
  • 1,258
  • 3
  • 18
  • 39

1 Answers1

12

You can use the email criteria. If you have the value %% it will retrieve all registered users.

Liam de Haas
  • 1,258
  • 3
  • 18
  • 39
  • 4
    A similar but perhaps more intuitive and useful variant of this approach is to use the `deleted` field and the value `0`, that will return all users that have not been deleted. – Bart B Aug 04 '17 at 16:34
  • 1
    @BartB It works but actually it is not intended to as the warning shows when you do so: `"item": "deleted", "warningcode": "invalidfieldparameter", "message": "The search key 'deleted' is not supported, look at the web service documentation"` – wp78de Sep 28 '18 at 20:48
  • 4
    @wp78de everything you do to get all users is a 'hack' because that's not what this API call is really for. The problem is, there is no API call for getting all users – Bart B Oct 11 '18 at 13:51
  • 1
    Actually everything seems to work as a search criteria, even if it does not exist (i.e. `idontevenexist` instead of `deleted`) – debuglevel Apr 06 '21 at 22:46