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

New Web Service core_user_update_picture

XMLWordPrintable

    • MOODLE_31_STABLE
    • MOODLE_32_STABLE
    • MDL-56070-master
    • Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token in the mobile app service for one user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Upload an image to be used as your new profile image via curl (replace the filedata and token)

        curl -i -F filedata=@/Users/juanleyvadelgado/Documents/jleyva.jpeg "http://localhost/m/stable_master/webservice/upload.php?token=ffbe3a3002f235bf9d01fd9369e10b66&filearea=draft"

      4. The itemid returned by the previous function will be the draftitemid for the next request:
      5. Next, you can do a CURL REST call simulating a WS client with the user to replace your image
        • You need to replace the wstoken, draftitemid (itemid of the previous request) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=458584267&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      6. Log out from Moodle, log in again and check that your see your now profile image
      7. Now, delete the image:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=0&delete=1&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      8. Log out and log in again to check that you see the Moodle default image
      9. You can optionally check that the WS don't work if you are trying to edit a mnet user, or a user using an authentication method that does not allow profile editing. There is also a global setting for disabling user profile images, you can enable that to check that the WS fails
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token in the mobile app service for one user: Click on Site administration ► Plugins ► Web services ► Manage tokens Upload an image to be used as your new profile image via curl (replace the filedata and token) curl -i -F filedata=@/Users/juanleyvadelgado/Documents/jleyva.jpeg "http://localhost/m/stable_master/webservice/upload.php?token=ffbe3a3002f235bf9d01fd9369e10b66&filearea=draft" The itemid returned by the previous function will be the draftitemid for the next request: Next, you can do a CURL REST call simulating a WS client with the user to replace your image You need to replace the wstoken, draftitemid (itemid of the previous request) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=458584267&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Log out from Moodle, log in again and check that your see your now profile image Now, delete the image: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'draftitemid=0&delete=1&wsfunction=core_user_update_picture&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Log out and log in again to check that you see the Moodle default image You can optionally check that the WS don't work if you are trying to edit a mnet user, or a user using an authentication method that does not allow profile editing. There is also a global setting for disabling user profile images, you can enable that to check that the WS fails

      Updates or deletes the user picture

            jleyva Juan Leyva
            jleyva Juan Leyva
            Dani Palou Dani Palou
            David Monllaó David Monllaó
            David Monllaó David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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