Tencent/APIJSON · error · IllegalArgumentException
POST 请求必须在Table内设置要保存的 key:value !
Error message
POST 请求必须在Table内设置要保存的 key:value !
What it means
Thrown on POST requests in gainColumnString when the table object has no column list at all — i.e. the request body's table object contains no key:value pairs to save. POST generates an INSERT column list from the table object's keys, so an empty object leaves nothing to build and the request is rejected.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java:2380
return StringUtil.isEmpty(group, true) ? "1" : "count(DISTINCT " + group + ")";
}
String[] args = start == end - 1 ? null : StringUtil.split(c0.substring(start + 1, end));
if (args != null && args.length > 0) {
List<String> raw = getRaw();
boolean containRaw = raw != null && raw.contains(KEY_COLUMN);
c0 = parseSQLExpression(KEY_COLUMN, c0, containRaw, false, null);
}
return "count(" + c0 + ")" + as + q + JSONResponse.KEY_COUNT + q;
}
}
return "count(" + (onlyOne ? gainKey(c0) : "*") + ")" + as + q + JSONResponse.KEY_COUNT + q;
// return SQL.count(onlyOne && StringUtil.isName(column.get(0)) ? getKey(column.get(0)) : "*");
case POST:
if (column == null || column.isEmpty()) {
throw new IllegalArgumentException("POST 请求必须在Table内设置要保存的 key:value !");
}
String s = "";
boolean pfirst = true;
for (String c : column) {
if (isPrepared() && StringUtil.isName(c) == false) {
// 不能通过 ? 来代替,SELECT 'id','name' 返回的就是 id:"id", name:"name",而不是数据库里的值!
throw new IllegalArgumentException("POST请求: 每一个 key:value 中的key都必须是1个单词!");
}
s += ((pfirst ? "" : ",") + gainKey(c));
pfirst = false;
}
return "(" + s + ")";
case GET:
case GETS:
String joinColumn = "";View on GitHub (pinned to 5284052872)
Solutions
- Add at least one real column to the table object, e.g. {"User":{"name":"aapi"}}.
- Check client code is not stripping all fields before POST — log the actual request body.
- Ensure @-prefixed operator keys are not the only keys; they do not count as savable columns.
- If you intend to query rather than insert, use GET/GETS instead of POST.
Example fix
// before
POST /post/User {"User":{}}
// after
POST /post/User {"User":{"name":"apijson","sex":1}} Defensive patterns
Strategy: validation
Validate before calling
const cols = Object.keys(table || {}).filter(k => !k.startsWith('@'));
if (cols.length === 0) throw new Error('POST needs at least one key:value in the table object'); Type guard
null
Try / catch
catch IllegalArgumentException on POST; show 'nothing to save' and re-prompt user
Prevention
- Disable the submit button until at least one field is set
- Log outbound POST bodies in dev builds to catch empty objects
- Remember @-keys are operators, not savable columns
When it happens
Trigger: POST /post/User with body {"User":{}} or {"User":{"@explain":true}} where the only keys are @-prefixed operator keys (which never become columns). Also when a client serializes an empty form/model to JSON and posts it unchanged.
Common situations: Submitting an empty form because all input fields were optional and left blank; accidentally wrapping values one level too deep (e.g. {"User":{"User":{...}}}) so the outer table object is empty; test scripts posting a placeholder object.
Related errors
- POST请求: 每一个 key:value 中的key都必须是1个单词!
- HEAD请求: 字符 {alias} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的
- HEAD请求: 字符{origin} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的
- HEAD请求: 字符 {origin.substring(0, start)} 不合法!预编译模式下 @column:v
- @column:value 的 value 中字符串 {expression} 不合法!不允许传超过 100 个字符的函
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/0d6066556edd75ec.
Report an issue: GitHub.