archive/pages/{pageid}/restore (POST)
Overview
Restore all revisions of a given page
- REST Method: POST
- Method Access: public
Uri Parameters
Name | Type | Description |
pageid | int | An integer page ID from GET: archive/pages |
Query Parameters
Name | Type | Description |
authenticate | bool? | Force authentication for request (default: false) |
reason | string? | Reason for reverting |
to | string | new page title |
Return Codes
Name | Value | Description |
OK | 200 | The request completed successfully |
Forbidden | 403 | Administrator access is required |
Not Found | 404 | Unable to find the page to delete |
Conflict | 409 | A title with the same path already exists. To restoring to a different path with '?to=' |
Message Format
Output:
<pages.restored> <page id="{id}" href="{uri}"> <title>{text}</title> <path>{text}</path> </page> </pages.restored>
Implementation Notes
Use GET:archive/pages to retrieve a list of pages currently in the archive.
When a page is restored, it is moved from the page archive to the specified location. If a new page already exists at this location, the restore will fail until this page has been removed or renamed.
Note that this feature does not restore files attached to the specified page.
C# Code Sample: Restore a Page
The following code example restores archived page ID 10168 to the title RestoredPage:
Sample Code
Plug p = Plug.New("http://deki-hayes/@api/deki"); p.At("users", "authenticate").WithCredentials("admin", "password").Get(); p.At("archive", "pages", "10168", "restore").With("to", "RestoredPage").Post();
Sample Response from executing Code
<pages.restored> <page id="10168" href="http://deki-hayes/@api/deki/pages/10168"> <title>RestoredPage</title> <path>RestoredPage</path> </page> </pages.restored>
Curl Code Sample: Restore a Page
This following command restores page with page.archiveID = 1.
Sample Code
curl -u admin:password -H "Content-Type: text/plain" -d "" -i http://mindtouch.address/@api/deki/archive/pages/1/restore
Implementation notes
curl flags
- -u
- Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
- -d
- Specifies a POST request. The quotations ("") are used to imply no data is to be sent.
- -H
- Replaces or appends an HTTP header. The "Content-Type" header specifies the MIME type of the value attached to the property. In this case, it does not really matter, but use text/plain as a precaution.
- -i
- Includes the HTTP response header in the output. Useful for debugging.
Permissions
- ADMIN permission is required to execute above command. Otherwise, a 403 HTTP response (Forbidden) will be returned.
Example
A contributor has vandalized and deleted a page with page.archiveID = 567. The following command will restore the page and its revisions:
curl -u admin:password -H "Content-Type: text/plain" -d "" -i http://192.168.59.128/@api/deki/archive/pages/567/restore
HTTP Response Headers
HTTP/1.1 200 OK Date: Tue, 19 Jan 2010 19:30:03 GMT Server: Dream-HTTPAPI/2.0.0.17629 Microsoft-HTTPAPI/2.0 Content-Length: 225 Content-Type: application/xml; charset=utf-8 X-Data-Stats: request-time-ms=134; mysql-queries=24; mysql-time-ms=93; X-Deki-Site: id="default" Via: 1.1 dekiwiki
HTTP Response Body
Content-Type: application/xml
<?xml version="1.0"?> <pages.restored> <page id="567" href="http://192.168.59.128/@api/deki/pages/567?redirects=0"> <uri.ui>http://192.168.59.128/FUBAR</uri.ui> <title>FUBAR</title> <path>FUBAR</path> <namespace>main</namespace> </page> </pages.restored>
Notes
- To view the XML data of a list of all archived pages, follow the path: /@api/deki/archive/pages. For instance, the path for the above example would be http://192.168.59.128/@api/deki/archive/pages.