Tencent/APIJSON · error · IllegalArgumentException
不支持在 中 !
Error message
不支持在 ${method} 中 ${_method} ! What it means
For non-CRUD endpoints, every table object's resolved method must exactly equal the URL method; the parser throws '不支持在 X 中 Y !' when an object declares a different method. This is a deliberate security guard so a /get request cannot smuggle a write via per-object @method.
Solutions
- Match the object method to the URL: use /crud if one request must mix methods
- Or delete the per-object @method / method directive so it inherits the URL method
- Audit shared request templates for leftover @method keys
Example fix
// before
POST /get {"User": {"@method": "PUT", "id": 1}}
// after
POST /crud {"User": {"@method": "PUT", "id": 1}} // or drop @method on /get Defensive patterns
Strategy: validation
Validate before calling
if (urlMethod !== 'CRUD') {
for (const [tbl, obj] of Object.entries(req)) {
const m = obj?.['@method'];
if (m && m.toUpperCase() !== urlMethod.toUpperCase()) {
throw new Error(`${tbl}: @method ${m} conflicts with URL ${urlMethod}; use /crud`);
}
}
} Type guard
const methodMatchesUrl = (m, url) => url === 'CRUD' || !m || m.toUpperCase() === url.toUpperCase();
Try / catch
try { await client.invoke(url, req); } catch (e) { if (e.message.includes('不支持在')) rerouteToCrud(url, req); else throw e; } Prevention
- Route mixed-method requests to /crud by design
- Never carry @method across endpoint changes; regenerate templates per endpoint
When it happens
Trigger: POST /get with "User": {"@method": "PUT"}; /put endpoint containing an object declared as POST; any non-CRUD URL where attrMap/method directive sets a mismatched per-object method.
Common situations: Reusing one generic request body across endpoints; migrating an endpoint from /crud to /get but keeping per-object @method values; method directive @put inside a /get request.
Related errors
- : 里的 @combine:value 不合法!开放请求 GET、HEAD 才允许传 @combine:value !
- 字符串 不合法!预编译模式下…
- 写操作请求必须带条件!!!
- 字符 不合法!预编译模式下 中 function 必须符合小写英文单词的 SQL 函数名格式!且必须是后端允许调用的…
- key[]: 只支持 GET, GETS 方法!其它方法不允许传 : 等这种 key[]: 格式!
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/5f9917bdf13095ca.
Report an issue: GitHub.
Appendix: source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractParser.java:2505
if (method == RequestMethod.CRUD) {
_method = GET;
Map<String, Object> objAttrMap = new HashMap<>();
objAttrMap.put(KEY_METHOD, GET);
keyObjectAttributesMap.put(key, objAttrMap);
} else {
_method = method;
Map<String, Object> objAttrMap = new HashMap<>();
objAttrMap.put(KEY_METHOD, method);
keyObjectAttributesMap.put(key, objAttrMap);
}
} else {
_method = (RequestMethod) attrMap.get(KEY_METHOD);
}
}
// 非 CRUD 方法,都只能和 URL method 完全一致,避免意料之外的安全风险。
if (method != RequestMethod.CRUD && _method != method) {
throw new IllegalArgumentException("不支持在 " + method + " 中 " + _method + " !");
}
// get请求不校验
if (RequestMethod.isPublicMethod(_method)) {
correctRequest.put(key, obj);
continue;
}
if (tag != null && ! tag.contains(":")) {
M object = getRequestStructure(_method, tag, version);
M ret = objectVerify(_method, tag, version, name, request, maxUpdateCount, creator, object);
correctRequest.putAll(ret);
break;
}
String _tag = buildTag(request, key, method, tag);
M object = getRequestStructure(_method, _tag, version);
if (method == RequestMethod.CRUD && StringUtil.isEmpty(tag, true)) {View on GitHub (pinned to 5284052872)