languagetool-org/languagetool · error · BadRequestException
Missing 'language' parameter, e.g. 'language=en-US' for Amer
Error message
Missing 'language' parameter, e.g. 'language=en-US' for American English or 'language=fr' for French
What it means
V2 of the LanguageTool HTTP API requires the 'language' parameter; it is missing or empty. The message also shows example values ('en-US', 'fr'). V2TextChecker.checkParams() calls super and then validates language first, before any other parameter checks.
Source
Thrown at languagetool-server/src/main/java/org/languagetool/server/V2TextChecker.java:98
return enabledRules;
}
@NotNull
@Override
protected List<String> getDisabledRuleIds(Map<String, String> parameters) {
return getCommaSeparatedStrings("disabledRules", parameters);
}
@Override
protected boolean getLanguageAutoDetect(Map<String, String> parameters) {
return "auto".equals(parameters.get("language"));
}
@Override
protected void checkParams(Map<String, String> parameters) {
super.checkParams(parameters);
if (StringTools.isEmpty(parameters.get("language"))) {
throw new BadRequestException("Missing 'language' parameter, e.g. 'language=en-US' for American English or 'language=fr' for French");
}
if (parameters.get("enabled") != null) {
throw new BadRequestException("You specified 'enabled' but the parameter is now called 'enabledRules' in v2 of the API");
}
if (parameters.get("disabled") != null) {
throw new BadRequestException("You specified 'disabled' but the parameter is now called 'disabledRules' in v2 of the API");
}
if (parameters.get("preferredvariants") != null) {
throw new BadRequestException("You specified 'preferredvariants' but the parameter is now called 'preferredVariants' (uppercase 'V') in v2 of the API");
}
if (parameters.get("autodetect") != null) {
throw new BadRequestException("You specified 'autodetect' but automatic language detection is now activated with 'language=auto' in v2 of the API");
}
}
@Override
@NotNull
protected DetectedLanguage getLanguage(String text, Map<String, String> parameters, List<String> preferredVariants,View on GitHub (pinned to 2e990059ce)
Solutions
- Add language=en-US (or the desired code) to the request
- Use language=auto for automatic language detection
- Fetch valid codes from /v2/languages
- Ensure empty-string values are not stripped or replaced by your HTTP client
Example fix
// before
params.put("text", text);
// after
params.put("text", text);
params.put("language", "en-US"); Defensive patterns
Strategy: validation
Validate before calling
if (!params.language) throw new Error("'language' is required for /v2/check, e.g. language=en-US"); Type guard
const hasLanguage = (p) => typeof p.language === 'string' && p.language.length > 0;
Try / catch
try { await check(params); } catch (e) { if (/Missing 'language' parameter/.test(e.message)) { params.language = 'auto'; return check(params); } throw e; } Prevention
- Always set language (or language=auto)
- Don't strip empty-looking but meaningful defaults from request maps
- Add a request-builder that enforces required v2 fields
When it happens
Trigger: POST/GET to /v2/check without a language parameter, or with language= (empty); SDK calls that omit language when not using auto-detection explicitly.
Common situations: Migrating clients from v1 where language was optional with autodetect; copied example code that dropped the parameter; form handlers dropping empty fields from the request body.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- This end point needs a user id
- Only either 'text' or 'markup' are supported in an object in
- 'text' cannot be used with 'interpretAs' (only 'markup' can)
- Only 'text' and 'markup' are supported in 'annotation' list:
- With 'username' set, you also need to specify 'apiKey'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/8bcba828b48c54de.
Report an issue: GitHub.