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

Invalid return parameters definition in core_files_get_files Web Service

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MDL-46586-master
    • Hide

      Inside the Miscellanous category create a course named "Test course: S"

      Enable "Mobile services" Plugins / Web Services / Services

      Create a new service in the same page, include in that service the function: core_files_get_files

      Create a Token for any user that can view the courses in that category and for the service you created before:
      Click on Site administration ► Plugins ► Web services ► Manage tokens
      Click add, select user and service

      Next, you can do a CURL REST call simulating a WS client request:

      You need to change:

      • The URL pointing to your Moodle site
      • The wstoken value: The one you created
      • The contextid: Verify that the Miscellaneous category context id is 3

       
      curl 'http://localhost/m/stable_27/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' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) 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 'contextid=3&component=&filearea=&itemid=0&filepath=&filename=Miscellaneous&wsfunction=core_files_get_files&wstoken=a94d048ece53cd8284c35af81eebee72' --compressed
      
      

      You should receive a JSON string containing a list of parent directories and also a list including the courses in that category

      Show
      Inside the Miscellanous category create a course named "Test course: S" Enable "Mobile services" Plugins / Web Services / Services Create a new service in the same page, include in that service the function: core_files_get_files Create a Token for any user that can view the courses in that category and for the service you created before: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and service Next, you can do a CURL REST call simulating a WS client request: You need to change: The URL pointing to your Moodle site The wstoken value: The one you created The contextid: Verify that the Miscellaneous category context id is 3   curl 'http://localhost/m/stable_27/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' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) 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 'contextid=3&component=&filearea=&itemid=0&filepath=&filename=Miscellaneous&wsfunction=core_files_get_files&wstoken=a94d048ece53cd8284c35af81eebee72' --compressed You should receive a JSON string containing a list of parent directories and also a list including the courses in that category

      filename params should be always PARAM_TEXT because some times files are directories with names that doesn't match the PARAM_FILE rules. This happens mainly when browsing the "files tree" structure that includes category and course names

      For example, browsing the file tree inside a course category may fail if a course with a name "Test course: S" exists

      {"exception":"invalid_response_exception","errorcode":"invalidresponse","message":"Invalid response value detected","debuginfo":"files => Invalid response value detected: filename => Invalid response value detected: Invalid external api response: the value is \"Test course: S\", the server was expecting \"file\" type"}
      

            jleyva Juan Leyva
            jleyva Juan Leyva
            Mark Nelson Mark Nelson
            Dan Poltawski Dan Poltawski
            Jetha Chan Jetha Chan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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