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

New web service core_files_get_unused_draft_itemid

XMLWordPrintable

    • MOODLE_310_STABLE
    • MOODLE_311_STABLE
    • MDL-70387-master
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for any user in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours.

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_files_get_unused_draft_itemid&wstoken=WSTOKEN' | python -m "json.tool"

      4. Confirm that:
        • The value for the component field is user
        • The value for the filearea field is draft
        • The value for the userid field is the user making the request id
      5. Copy somewhere the returned itemid
      6. Execute the following curl request pointing to a file in your local system (it will upload a file) you will have to replace the LOCAL_PATH_TO_FILE, ITEMID and WSTOKEN values apart from the SITEURL:

        curl -i -F name=filename.ext -F filedata=@/LOCAL_PATH_TO_FILE/filename.ext "SITEURL/webservice/upload.php?token=WSTOKEN&filearea=draft&itemid=ITEMID"

      7. Confirm that:
        • As the request response, you see a json
        • The contextid, component, filearea and itemid values matches the ones from the initial request

       
       

      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for any user in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_files_get_unused_draft_itemid&wstoken=WSTOKEN' | python -m "json.tool" Confirm that: The value for the component field is user The value for the filearea field is draft The value for the userid field is the user making the request id Copy somewhere the returned itemid Execute the following curl request pointing to a file in your local system (it will upload a file) you will have to replace the LOCAL_PATH_TO_FILE, ITEMID and WSTOKEN values apart from the SITEURL: curl -i -F name=filename.ext -F filedata=@/LOCAL_PATH_TO_FILE/filename.ext "SITEURL/webservice/upload.php?token=WSTOKEN&filearea=draft&itemid=ITEMID" Confirm that: As the request response, you see a json The contextid, component, filearea and itemid values matches the ones from the initial request    

      New WS for retrieving an unused draft item id for external systems.

      To be used when we need to manipulate/create temporary draft file areas from external systems (see MDL-69952 for a user case)

            jleyva Juan Leyva
            jleyva Juan Leyva
            Pau Ferrer Pau Ferrer
            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 - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 10 minutes
                3h 10m

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