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

Web services should not use status 200 for exceptions

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.7.2, 4.3
    • Web Services
    • None
    • MOODLE_37_STABLE, MOODLE_403_STABLE

      When Moodle's built-in web services return an exception, this is often or always returned with an HTTP status 200. For example, if we submit a request to mod_assign_save_grade with an invalid parameter, we receive the response:

      Exception: invalid_parameter_exception
      Error Code: invalidparameter
      Message: Invalid parameter value detected
      

       
      This is returned with an HTTP status code 200 (OK). The 200 code is supposed to indicate that a request succeeded. It is not the appropriate code to use if we passed in bad parameters and got back an exception. A more appropriate code for this example would be 400 (Bad Request).

      Use of the correct HTTP status codes would allow our client-side code to more elegantly handle  responses from the server without having to parse every single response for exceptions.

            Unassigned Unassigned
            kevinfoley Kevin Foley
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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