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

New web service tool_mobile_call_external_functions

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Future Dev
    • Fix Version/s: 3.7
    • Component/s: Administration
    • Labels:
    • Testing Instructions:
      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).
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull Master Branch:
      MDL-64642-master

      Description

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              albert.gasset Albert Gasset
              Reporter:
              albert.gasset Albert Gasset
              Peer reviewer:
              Carlos Escobedo
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Anna Carissa Sadia
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                20/May/19

                  Time Tracking

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