You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Moodle批量上传用户报错Invalid parameter value detected求助

批量上传用户时的参数格式错误问题

使用Postman通过xlsx文件批量上传用户,调用Web Service时返回以下错误:

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" }

当前发送的数组结构如下:

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) "pprub02@gmail.com"
        }
      }
    }
  }
}

问题出在数组的嵌套层级错误——你多套了一层["users"]结构。服务端期望的是users字段直接包含用户对象数组,而不是在数组元素里再嵌套一个users数组。

修正后的正确数组结构应该是:

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) "pprub02@gmail.com"
    }
  }
}

调整后,服务端就能正确识别每个用户对象里的username字段,解决参数无效的问题。

内容的提问来源于stack exchange,提问作者Meyer Restrepo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 06:22:13