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

New web service tool_mobile_call_external_functions

XMLWordPrintable

    • MOODLE_37_STABLE
    • MDL-64642-master
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a user: user1
      3. Create a token for that user in Site administration ► Plugins ► Web services ► Manage tokens
      4. Do the following HTTP request (use the URL, wstoken and username of your site): 

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=tool_mobile_call_external_functions&requests[0][function]=tool_mobile_get_public_config&requests[1][function]=core_user_get_users_by_field&requests[1][arguments]= {"field": "username", "values":["user1"]}&wstoken=2648258649bb6f8d60b7439dc02a0ecf' | jq

      1. Check the response contains a "responses" field with two items:
        1. The "data" of the 1st response contains the info of the site (encoded as JSON). The "error" is false.
        2. The "data" of the 2nd response contains the info of the user (encoded as JSON). The "error" is false.

       

      Note: if you don't have jq tool, you can use python -m "json.tool" instead. So, in linux you can install jq this way (sudo apt-get install jq), in Mac (brew install jq).

      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a user: user1 Create a token for that user in Site administration ► Plugins ► Web services ► Manage tokens Do the following HTTP request (use the URL, wstoken and username of your site):  curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=tool_mobile_call_external_functions&requests [0] [function] =tool_mobile_get_public_config&requests [1] [function] =core_user_get_users_by_field&requests [1] [arguments] = {"field": "username", "values": [" user1 "] }&wstoken= 2648258649bb6f8d60b7439dc02a0ecf ' | jq Check the response contains a "responses" field with two items: The "data" of the 1st response contains the info of the site (encoded as JSON). The "error" is false. The "data" of the 2nd response contains the info of the user (encoded as JSON). The "error" is false.   Note : if you don't have jq tool, you can use python -m "json.tool" instead. So, in linux you can install jq this way (sudo apt-get install jq), in Mac (brew install jq).

      Web service for calling multiple external functions, so we can reduce the number of HTTP requests sent from the mobile app.

            albert.gasset Albert Gasset
            albert.gasset Albert Gasset
            Carlos Escobedo Carlos Escobedo
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 5 minutes
                2h 5m

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