c++ - Moodle REST webservice: Problems sending an array as POST parameter -
I am using Moodle Rest WebSaver in conjunction with QT. Login works, other functions with single parameters are also working.
Now I want to use the function "core_user_update_users" which takes an array as the parameter.
The official documentation says:
The general structure:
(User username string object {id int // ID} Optional // username policy is defined in the Moodle Security config ... more optional string custom field not optional // user custom fields (known as user profile field) list (object {type string // custom field values string The // value of the custom field}) preferences optional user / user preference list (object {type string // value name / priority Priority value string})}) and < / P>
REST (post parameter)
user [0] [id] = int user [0] [user name] = string // optional // multiple parameters, but above All the alternatives like
So I thought this would be my HTT P requests:
Auto Netvrkpostarkvenst = QNetworkRequest (QUrl ( "http://XXX.XXX.XXX.XXX/webservice/rest/server.php?wstoken=XXXXXXXXX&moodlewsrestformat=json&wsfunction = Core_user_update_users")); NetworkPostRequest.setHeader (QNetworkRequest :: ContentTypeHeader, "application / x-www-form-urlencoded"); QByteArray data; Data.append ("those [0] [id] = 12"); Data.append ("& amp; those [0] [FIRSTNAME] = QtTestname"); This- & gt; NetworkAccessManager- & gt; Put (NetworkPostRequest, data);
But I get the following debugme from Moodle:
{"debuginfo": "missing the required key in a single composition "invalid parameter", "exception": "invalid_parameter_exception", "message": "invalid parameter value detected"}
obviously with some data It is wrong, but I can not understand it. Hopefully someone can help here.
solution "For the first attachment of data.
QByteArray data; Data.append ("& amp; those [0] [id] = 12"); Data.append ("& amp; those [0] [FIRSTNAME] = QtTestname"); This- & gt; NetworkAccessManager- & gt; Put (NetworkPostRequest, data); In the form of logic, the Moodle function is not regarded without any array, so I have not noticed yet.
Comments
Post a Comment