"Invalid parameter value deteced" moodle

30 views Asked by At

I am experiencing this problem when performing bulk upload via xlsx file in postman. I get the problem when I run the web service through curl:

object(stdClass)#291 (4) { ["exception"]=> string(27) "invalid_parameter_exception" ["errorcode"]=> string(16) "invalidparameter" ["message"]=> string(32) "Invalid parameter value detected" ["debuginfo"]=> string(93) "users => Invalid parameter value detected: Missing required key in single structure: username" }

I am sending an array as follows:

array(1) {
  ["users"]=>
  array(1) {
    [0]=>
    array(1) {
      ["users"]=>
      array(1) {
        [0]=>
        array(6) {
          ["username"]=>
          string(11) "userprueba"
          ["password"]=>
          string(10) "TestPass1!"
          ["firstname"]=>
          string(4) "PEPE"
          ["lastname"]=>
          string(8) "RUBIALES"
          ["idnumber"]=>
          string(10) "3601611842"
          ["email"]=>
          string(17) "[email protected]"
        }
      }
    }
  }

I have already reviewed the site policies and I am submitting the data accordingly. However the problem persists. I suspect that the problem is in the way the array is being sent, but I have not found a solution.

I appreciate your help, thank you!

2

There are 2 answers

1
Russell England On

Which web service are you using? Is it core_user_update_users ?

You can check the array structure in Moodle at

Site admin > Server > Web Services > API Documentation > core_user_create_users

eg:

[users] =>
    Array 
        (
        [0] =>
            Array 
                (
                [username] => string                
                [auth] => string                
                [password] => string                
                [firstname] => string                
                [lastname] => string                
                [email] => string                
                [idnumber] => string                
                )
        )

It looks like you have 2 [users] arrays, there should only be one

array(1) {
  ["users"]=>
  array(1) {
    [0]=>
    array(1) {
      ["users"]=>
      array(1) {
0
Meyer Restrepo On

Solved. In case anyone has the same problem: I actually restructured the way I was submitting users. Send each user one by one for API consumption and it is also very important to send it as an array. I couldn't send the array with all the users, if I'm not wrong you can only receive one per service.