Web service function in custom plugin to receive json input

Web service function in custom plugin to receive json input

by Евгений Мамаев -
Number of replies: 1
Picture of Plugin developers

I have a custom plugin (local) which has an external function (web service function). I need to get a json payload as an input parameter to this function. Is it possible?

Average of ratings: -
In reply to Евгений Мамаев

Re: Web service function in custom plugin to receive json input

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
Hi,

By payload are you talking about a file or just JSON text? In both cases, you can. For text, you may have to define the parameter as PARAM_RAW. If you are talking a JSON file, then you will have to use the $_FILES global however you will need to define an input parameter for the file even if it is always empty.

Hope that helps.