API:Edit - Delete
From MediaWiki.org
| This page is part of the MediaWiki API documentation. |
MediaWiki version: 1.12
Contents |
[edit] Token
To delete a page, a delete token is required. This token is equal to the edit token and the same for all pages, but changes at every login. A delete token can be obtained as follows: Obtaining a delete token
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page pageid="1" ns="0" title="Main Page" touched="2007-09-03T20:32:21Z" lastrevid="20" counter="20" length="470" deletetoken="58b54e0bab4a1d3fd3f7653af38e75cb+\" /> </pages> </query> </api>
[edit] Deleting pages
Pages can be deleted with action=delete.
[edit] Parameters
- title: The page you want to delete.
- pageid: The page id of the page you want to delete
- token: The token obtained in the previous request. Take care to urlencode the trailing
+\as%2B%5C. - reason: The reason for the deletion (optional). If not provided, an automatically generated reason will be used.
[edit] Example
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=delete requires POST requests; GET requests will cause an error. Deleting the Main Page with an auto-generated reason
<?xml version="1.0" encoding="utf-8"?> <api> <delete title="Main Page" reason="content was: 'content goes here' and the only contributor was Username" /> </api>
[edit] Possible errors
In addition to the usual stuff:
- code: notitle
- info: The title parameter must be set
- code: notoken
- info: The token parameter must be set
- code: permissiondenied
- info: You don't have permission to delete pages
- On most wikis, deleting pages is restricted to sysops, but other wikis may have stricter rules.
- info: You don't have permission to delete pages
- code: cantdelete
- info: Couldn't delete ``title''. Maybe it was deleted already by someone else