API:Errors and warnings
![]() |
This page is part of the MediaWiki API documentation. |
Language: | English • Deutsch • español • français • 日本語 • 한국어 |
---|
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Search suggestions
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
If something goes wrong in an API request, an error or a warning will be thrown. Warnings are thrown for non-fatal conditions such as invalid parameters, whereas errors are only thrown for fatal conditions.
Contents
Warnings[edit | edit source]
Warnings are output in the following format:
<?xml version="1.0" encoding="utf-8"?> <api> <warnings> <query>Warning text Another warning</query> <info>A warning from prop=info</info> </warnings> </api>
As shown in the example, warnings are grouped by the name of the module that caused them. Multiple warnings from the same module are separated by a newline.
Disabled modules[edit | edit source]
Disabled action=query
submodules will always throw the following warning:
- The ``modulename'' module has been disabled.
Parameter validation warnings[edit | edit source]
The following warnings can be thrown when validating parameters, and can therefore be thrown by all modules. paramname
is replaced by the name of the parameter.
- Too many values supplied for parameter 'paramname': the limit is limit
- Unrecognized value for parameter 'paramname': value
- Unrecognized values for parameter 'paramname': value1, value2, value3
Errors[edit | edit source]
Error messages are output in the following format:
<error code="code" info="info" />
Where code
is replaced with a short error code (which need not be unique to the error) and info
with a more elaborate description of the error (which is unique). Also, the error code will be returned in the MediaWiki-API-Error
HTTP header. For an example error response or to test your client's error handling, see http://en.wikipedia.org/w/api.php?action=blah
Note that when viewing errors in pretty-print formats, the API help will be returned inside the <error>
element. To save bandwidth, this doesn't happen for non-pretty-print formats; if you specifically want the help text in a non-pretty-print format, use action=help
.
Error messages in the documentation[edit | edit source]
Error messages are documented as follows:
- code: apparams
- info: prlevel may not be used without prtype
Which corresponds to:
<error code="apparams" info="prlevel may not be used without prtype" />
Disabled modules[edit | edit source]
Disabled action=
modules will always fail with the following error:
- code: moduledisabled
- info: The ``modulename'' module has been disabled.
Parameter validation errors[edit | edit source]
The following errors can be thrown when validating parameters, and can therefore be thrown by all modules. paramname
is replaced by the name of the parameter.
- code: multival_paramname
- info: Only one of 'value1', 'value2', 'value3' is allowed for parameter 'paramname'
- code: unknown_paramname
- info: Unrecognized value for parameter 'paramname': value
- code: paramname
- info: paramname may not be set to less than min (set to value)
- code: paramname
- info: paramname may not be set over max (set to value) for bots and sysops
- code: paramname
- info: paramname may not be set over max (set to value) for users
- code: badtimestamp_paramname
- info: Invalid value value for timestamp parameter paramname
- code: baduser_paramname
- info: Invalid value value for user parameter paramname
- code: invalidparammix
- info: The parameters param1, param2, param3 cannot be used together
- code: missingparam
- info: One of the parameters param1, param2, param3 is required
- code: _badcontinue
- info: Invalid continue param. You should pass the original value returned by the previous query
Standard error messages[edit | edit source]
Some generic error messages are shared among modules. If a module can throw these errors, that's explicitly mentioned in its Possible errors
section.
- code: unknownerror
- info: Unknown error
- This usually means something crazy like a rare race condition occurred. If you get this error, retry your request until it succeeds or returns a more informative error message
- info: Unknown error
- code: unknownerror
- info: Unknown error errorcode
- code: unsupportednamespace
- info: Pages in the Special namespace can't be edited
- code: protectednamespace-interface
- info: You're not allowed to edit interface messages
- code: protectednamespace
- info: You're not allowed to edit pages in the ``namespace'' namespace
- code: customcssjsprotected
- info: You're not allowed to edit custom CSS and JavaScript pages
- code: cascadeprotected
- info: The page you're trying to edit is protected because it's included in a cascade-protected page
- code: protectedpage
- info: The ``right'' right is required to edit this page
- code: permissiondenied
- info: Permission denied
- code: confirmemail
- info: You must confirm your e-mail address before you can edit
- code: blocked
- info: You have been blocked from editing
- code: autoblocked
- info: Your IP address has been blocked automatically, because it was used by a blocked user
- code: ratelimited
- info: You've exceeded your rate limit. Please wait some time and try again
- code: readonly
- info: The wiki is currently in read-only mode
- code: badtoken
- info: Invalid token
- code: missingtitle
- info: The page you requested doesn't exist
- code: mustbeposted
- info: Type of your HTTP request message must be POST
- code: hookaborted
- info: The modification you tried to make was aborted by an extension hook
- code: nosuchpageid
- info: There is no page with ID id
- code: nosuchrevid
- info: There is no revision with ID id
- code: nosuchrcid
- info: There is no change with rcid ``id''
- code: nosuchuser
- info: The user you specified doesn't exist
- code: invalidtitle
- info: Bad title ``title''
- code: invaliduser
- info: Invalid username ``username''