Semantic-Org/Semantic-UI · error
Missing a required URL parameter:
Error message
Missing a required URL parameter:
What it means
This error is logged by the API module's add.urlData() function (api.js:372-374) when a URL template contains a required variable (e.g., '/users/{$id}') that cannot be resolved to a value. The function searches urlData, element data ($module.data), and context data ($context.data) for each required variable; if none is found, it logs this error with the variable name and returns false, aborting the request.
Source
Thrown at src/definitions/behaviors/api.js:1139
onAbort : function(errorMessage, $module) {},
successTest : false,
// errors
error : {
beforeSend : 'The before send function has aborted the request',
error : 'There was an error with your request',
exitConditions : 'API Request Aborted. Exit conditions met',
JSONParse : 'JSON could not be parsed during error handling',
legacyParameters : 'You are using legacy API success callback names',
method : 'The method you called is not defined',
missingAction : 'API action used but no url was defined',
missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',
missingURL : 'No URL specified for api event',
noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',
noStorage : 'Caching responses locally requires session storage',
parseError : 'There was an error parsing your request',
requiredParameter : 'Missing a required URL parameter: ',
statusMessage : 'Server gave an error: ',
timeout : 'Your request timed out'
},
regExp : {
required : /\{\$*[A-z0-9]+\}/g,
optional : /\{\/\$*[A-z0-9]+\}/g,
},
className: {
loading : 'loading',
error : 'error'
},
selector: {
disabled : '.disabled',
form : 'form'
},View on GitHub (pinned to 597843ab84)
Solutions
- Provide the required variable in settings.urlData: $('.el').api({ url: '/users/{$id}', urlData: { id: 42 } }).
- Set the variable as a data attribute on the element: <button data-id='42' class='ui button'>.
- Set the variable on the context element (usually the closest form or container with data-context).
- If the variable is genuinely optional, use the optional syntax {/var} instead of {var}.
Example fix
// before
$('.user-btn').api({
url: '/api/users/{$id}'
// no id provided anywhere
});
// after
$('.user-btn').api({
url: '/api/users/{$id}',
urlData: { id: getUserId() }
}); Defensive patterns
Strategy: validation
Validate before calling
// Validate required URL parameters are present before the request
function resolveUrl(url, urlData, $module, $context) {
var required = url.match(/\{\$?[A-Za-z0-9]+\}/g) || [];
var missing = required.filter(function(tok) {
var key = tok.replace(/[\{\}\$]/g, '');
return urlData[key] === undefined && $module.data(key) === undefined && ($context ? $context.data(key) : undefined) === undefined;
});
if (missing.length) {
console.error('Missing required URL parameters:', missing);
return false;
}
return url;
} Type guard
// Check if all required URL template variables have values
function hasAllRequiredParams(url, urlData, $module) {
var required = url.match(/\{[A-Za-z0-9]+\}/g) || [];
return required.every(function(tok) {
var key = tok.replace(/[\{\}\$]/g, '');
return urlData[key] !== undefined || $module.data(key) !== undefined;
});
} Prevention
- Provide all required URL variables in settings.urlData.
- Set required variables as data attributes on the element or context.
- Use the optional variable syntax {/var} for non-required parameters.
When it happens
Trigger: Configuring url: '/api/users/{$id}' but not providing id in settings.urlData, on the element via data-id, or on the context element via data-id. Also when the variable name in the template does not match the key provided in urlData (case sensitivity, typos).
Common situations: Dynamic elements where the data attribute is populated asynchronously and the API call fires before it is set. URL templates with variable names that don't match urlData keys. Forgetting to pass urlData in settings. Variable names containing special characters or being deeply nested.
Related errors
- API action used but no url was defined
- No URL specified for api event
- The beforeSend callback must return a settings object, befor
- The before send function has aborted the request
- There was an error with your request
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/f7d567ba54f5022e.
Report an issue: GitHub.