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

使用Postman调用Moodle API创建课程分类时遇参数无效错误

解决Moodle API创建课程分类时的invalid_parameter_exception错误

问题场景

通过Postman调用Moodle API创建课程分类时,返回参数无效错误:

invalidparameterInvalid parameter value detected

请求信息如下:

  • API端点:http://localhost/MyMoodle/webservice/rest/server.php
  • 请求方法:POST
  • Payload格式:x-www-form-urlencoded
  • 请求参数:
    • wstoken:<token>
    • wsfunction:core_course_create_categories
    • moodlewsrestfomat:json
    • categories[0][name]:Custom Cat 1
    • categories[0][parent]:0
    • categories[0][idnumber]:1
    • categories[0][description]:CustomCatdescription

排查与解决步骤

1. 修正参数拼写错误

你将格式参数moodlewsrestformat误写为moodlewsrestfomat(缺少字母r),这会导致Moodle无法正确识别请求格式,触发参数验证失败。修正为:
moodlewsrestformat:json

2. 确保idnumber唯一性

Moodle要求课程分类的idnumber在系统内唯一,若之前已存在idnumber=1的分类,重复提交会触发错误。建议更换为未使用过的标识,比如:
categories[0][idnumber]:custom_cat_1

3. 验证Token权限

确认wstoken对应的用户账号拥有moodle/category:manage权限——Moodle有时会用通用参数错误提示权限不足问题。可通过Moodle后台「站点管理」→「权限」→「分配角色」检查并配置权限。

4. 开启调试模式获取详细错误

若以上步骤仍未解决问题,开启Moodle调试模式查看具体无效参数:

  1. 登录Moodle后台,进入「站点管理」→「开发」→「调试」
  2. 将「调试信息」设置为「开发者级别(显示所有调试信息)」
  3. 重新发送请求,此时会返回具体的参数错误详情,便于精准排查。

内容的提问来源于stack exchange,提问作者Bhumi Shah

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.01 21:37:08