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

How to set parameter to null in a web service call

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0, Future Dev
    • Fix Version/s: DEV backlog
    • Component/s: Web Services
    • Labels:
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      This morning we had an interesting question wit Martin about to send a null parameter in a web service call.

      For example in the update_user function, we could have a field:
      'age' => new external_value(PARAM_INT, 'User age', VALUE_OPTIONAL),
      Imagine that the ws client wants to set this field to null. (because he entered a wrong age and finally he doesn't really know what is the user age.)

      In this case a solution could be:
      the ws client sends a '' or 'null' value. Then the external update_user function compare this value, and replace by php null, before to call the validate_parameters function.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              moodle.com moodle.com
              Reporter:
              jerome Jérôme Mouneyrac
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: