Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-46934

Web service function get_users_by_field does not return appropriate fields

XMLWordPrintable

    • MOODLE_27_STABLE, MOODLE_30_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • MDL-46934-master
    • Hide

      Request the JSON format. Add moodlewsrestformat=json to the request.

      Show
      Request the JSON format. Add moodlewsrestformat=json to the request.
    • Hide
      1. Login as admin
      2. Create a new user leaving as many fields blank as possible
        • Note its user name for later (substitute for the USERNAME in the CLI commands below)
      3. Go to Site administration ► Plugins ► Web services ► Mobile and tick Enable web services for mobile devices
      4. Create an external service in which core_user_get_users_by_field is added (You may also skip this and just use the built-in Moodle mobile web service)
      5. Go to Site administration ► Plugins ► Web services ► Manage tokens
      6. Create a token for the admin user in that service
      7. Open a terminal window in which you'll observe your Apache error log
        • Typically: {tail -f /var/log/apache2/error.log}
      8. Request the following:

        // Using HTTPie
        http -f WWWROOT/webservice/rest/server.php wstoken=TOKEN wsfunction=core_user_get_users_by_field field=username values[0]=USERNAME moodlewsrestformat=xml
         
        // Using curl
        curl WWWROOT/webservice/rest/server.php -d wstoken=TOKEN -d wsfunction=core_user_get_users_by_field -d field=username -d values[0]=USERNAME -d moodlewsrestformat=xml
        

      9. Confirm that there aren't any notices/errors about missing indexes in the logs
      10. Confirm that the XML structure is not broken (does not contain notices either)
      Show
      Login as admin Create a new user leaving as many fields blank as possible Note its user name for later (substitute for the USERNAME in the CLI commands below) Go to Site administration ► Plugins ► Web services ► Mobile and tick Enable web services for mobile devices Create an external service in which core_user_get_users_by_field is added (You may also skip this and just use the built-in Moodle mobile web service ) Go to Site administration ► Plugins ► Web services ► Manage tokens Create a token for the admin user in that service Open a terminal window in which you'll observe your Apache error log Typically: {tail -f /var/log/apache2/error.log} Request the following: // Using HTTPie http -f WWWROOT/webservice/rest/server.php wstoken=TOKEN wsfunction=core_user_get_users_by_field field=username values[0]=USERNAME moodlewsrestformat=xml   // Using curl curl WWWROOT/webservice/rest/server.php -d wstoken=TOKEN -d wsfunction=core_user_get_users_by_field -d field=username -d values[0]=USERNAME -d moodlewsrestformat=xml Confirm that there aren't any notices/errors about missing indexes in the logs Confirm that the XML structure is not broken (does not contain notices either)

      The web services function get_users_by_field for core_user_get_users_by_field does not return the full field list. This causes missing field warnings as the result set is serialised and returned.

            fred Frédéric Massart
            piers Piers Harding
            Jun Pataleta Jun Pataleta
            David Monllaó David Monllaó
            Adrian Greeve Adrian Greeve
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.