stojca
stojca

Reputation: 1

Moodle Web Service responses with invalid_parameter_exception

I created moodle and mariadb containers with Docker.

Moodle: 3.11.4

Mariadb: 10.3

I am trying following webservice to execute:

client:

wwwroot: 'http://localhost:8012',

service: 'moodle_mobile_app',

token: '8faf4879d2c654f11e404095032ae382',

strictSSL: true

call: curl "http://localhost:8012/webservice/rest/server.php?wstoken=8faf4879d2c654f11e404095032ae382&moodlewsrestformat=json&wsfunction=core_user_get_users_by_field&moodlewsrestformat=json&id=2"

but getting follwing error: {"exception":"invalid_parameter_exception","errorcode":"invalidparameter", "message":"Invalid parameter value detected (Missing required key in single structure:field)", "debuginfo":"Missing required key in single structure: field" }

I tried it same with moodle client for node

... client.call({ wsfunction: "core_user_get_users_by_field", method: "POST", args: { id: 2 } })... but also receiving same error. I checked API documentation and id is valid parameter for this webservice. Can you please help?

Upvotes: 0

Views: 609

Answers (1)

stojca
stojca

Reputation: 1

Issue is resolved

client.call({
    method: "POST",
    wsfunction: "core_user_get_users_by_field",
    args: {
        field: "id",
        values: ["2"]
    }
}).then(function(info) {
    var str = JSON.stringify(info, null, 4); 
    console.log(str);
});

Upvotes: 0

Related Questions