XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.9
    • 2.8.3
    • Web Services
    • MOODLE_28_STABLE
    • MOODLE_29_STABLE
    • MDL-48716-master
    • Hide

      Note: Version number is bumped because a new web service is added into the Mobile app service and also in a component.

      1. Enable "Mobile services": Plugins ► Web Services ► External services
      2. Create a Token for one user (student account):
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Next, do a couple of curl requests for creating devices .
        • First call, just copy and paste the request (you need to replace the wstoken and the URL of your moodle instance)
        • Second call, change the pushid and appid parameters with random values (different to the current ones)
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'appid=commoodlemobile&name=occam&model=Nexus&platform=Android&version=4&pushid=237823&uuid=ABCDEF&wsfunction=core_user_add_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
          

      4. Check that the two devices have been created in your local database (table prefix_user_devices)
      5. Now we are going to delete an non existent device, do the following request just replacen your token and URL

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data '&uuid=ZYXFDEASDFSDASDFDD&wsfunction=core_user_remove_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
        

      6. You should see and output like this one

        {"removed":false,"warnings":[{"item":"ZYXFDEASDFSDASDFDD","warningcode":"devicedoesnotexist","message":"The device doesn't exists in the database"}]}
        

      7. Now, try to remove the first device you created (remember to use your site and token):

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodl: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data '&uuid=ABCDEF&appid=commoodlemobile&wsfunction=core_user_remove_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
        

      8. You should see and output like this one

        {"removed":true,"warnings":[]}
        

      9. And now, remove the second device, as you can see we only indicate the uuid

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'uuid=ABCDEF&wsfunction=core_user_remove_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
        

      10. You should see and output like this one

        {"removed":true,"warnings":[]}
        

      11. If you do the curl request again, you should see removed: false and a warning
      Show
      Note: Version number is bumped because a new web service is added into the Mobile app service and also in a component. Enable "Mobile services": Plugins ► Web Services ► External services Create a Token for one user (student account): Click on Site administration ► Plugins ► Web services ► Manage tokens Next, do a couple of curl requests for creating devices . First call, just copy and paste the request (you need to replace the wstoken and the URL of your moodle instance) Second call, change the pushid and appid parameters with random values (different to the current ones) You also need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'appid=commoodlemobile&name=occam&model=Nexus&platform=Android&version=4&pushid=237823&uuid=ABCDEF&wsfunction=core_user_add_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed Check that the two devices have been created in your local database (table prefix_user_devices) Now we are going to delete an non existent device, do the following request just replacen your token and URL curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data '&uuid=ZYXFDEASDFSDASDFDD&wsfunction=core_user_remove_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed You should see and output like this one {"removed":false,"warnings":[{"item":"ZYXFDEASDFSDASDFDD","warningcode":"devicedoesnotexist","message":"The device doesn't exists in the database"}]} Now, try to remove the first device you created (remember to use your site and token): curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodl: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data '&uuid=ABCDEF&appid=commoodlemobile&wsfunction=core_user_remove_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed You should see and output like this one {"removed":true,"warnings":[]} And now, remove the second device, as you can see we only indicate the uuid curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'uuid=ABCDEF&wsfunction=core_user_remove_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed You should see and output like this one {"removed":true,"warnings":[]} If you do the curl request again, you should see removed: false and a warning

      When a user deletes a site in the app we need to call a remote Web Service in the Moodle site to remote the user device entry (that ws will also remove the device in the Airnotifier instance)

            jleyva Juan Leyva
            jleyva Juan Leyva
            Simey Lameze Simey Lameze
            Andrew Lyons Andrew Lyons
            David Monllaó David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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