public. Update contents of a page
| Name | Type | Description |
| pageid | string | either an integer page ID, "home", or "=" followed by a double uri-encoded page title |
| Name | Type | Description |
| abort | {never, modified, exists}? | specifies condition under which to prevent the save; default is never |
| authenticate | bool? | Force authentication for request (default: false) |
| comment | string? | the edit comment |
| edittime | string | the edit timestamp (yyyyMMddHHmmss or yyyy-MM-ddTHH:mm:ssZ |
| language | string? | the page language (default: determine culture from parent) |
| preservetitle | bool? | keep existing display title (default: false) |
| redirects | int? | If zero, do not follow page redirects. |
| section | int? | the section number. If zero, append as a new section |
| title | string? | the display title (default: determine title from page path) |
| xpath | string? | identifies the portion of the page to update; this parameter is ignored if section is specified |
| Name | Value | Description |
| BadRequest | 400 | Invalid input parameter or request body |
| Forbidden | 403 | Update access to the page is required |
| NotFound | 404 | Requested page could not be found |
| Ok | 200 | The request completed successfully |
Input:
Content-type=text/plain
Output:
<edit status="{success|conflict}">
<page id="{int}" href="{uri}">
<title>{text}</title>
<path>{text}</path>
</page>
<page.base id="{int}" revision="{int}" href="{uri}">
<title>{text}</title>
<path>{text}</path>
<date.edited>{date}</date.edited>
<user.author id="{int}" href="{uri}">
<nick>{text}</nick>
<username>{text}</username>
<email>{text}</email>
</user.author>
<description>{text}</description>
<contents type="{contenttype}" href="{uri}" />
</page.base>
<page.overwritten id="{int}" revision="{int}" href="{uri}">
<title>{text}</title>
<path>{text}</path>
<date.edited>{date}</date.edited>
<user.author id="{int}" href="{uri}">
<nick>{text}</nick>
<username>{text}</username>
<email>{text}</email>
</user.author>
<description>{text}</description>
<contents type="{contenttype}" href="{uri}" />
</page.overwritten>
</edit>
If the page does not exist, a new page is created. Otherwise, the existing page is updated.
Use the Abort parameter to control edit conflict behavior. Abort=exists specifies that the save should abort if the page already exists. Similarly, Abort=modified specifies that the save should abort if the page has been modified since the Edittime parameter. Abort=never always allows the save to occur; the system makes no attempt to merge edit conflicts and simply overwrites the existing content. If an edit conflict is detected (ie. someone else edited the page since the value specified in the Edittime parameter), the edit status is set to "conflict" and the page.base/page.overwritten elements are populated. The page.base element displays the revision upon which the changes in the current save were based. The page.overwritten element displays the page revision containing the overwritten content.
It is possible to update a portion of an existing page using either the Section or XPath parameters. The Section parameter contains the integer section number to update. Everything within the specified section is replaced, including the section heading itself. Section=0 specifies to append the new content to the end of the document. The XPath parameter identifies a document node to replace. Refer here for more information on XPath syntax.
The following code example creates a new page called "Subpage 1" under the page called "Page Title"; it will fail if the page already exists. The new page contents contains two sections:
Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
DreamMessage msg = DreamMessage.Ok(MimeType.TEXT, "<h2>Section 1</h2>Section 1 text<h2>Section2</h2>Section 2 text");
p.At("pages", "=Page_Title%252fSubpage_1", "contents").With("abort", "exists").Post(msg);
Sample response indicating that the page was successfully created:
<edit status="success">
<page id="84" href="http://deki-hayes/@api/deki/pages/84">
<title>Subpage 1</title>
<path>Page_Title/Subpage_1</path>
</page>
</edit>
UPDATE - Looks to be yyyymmddhhmmss. (And use UTC time, not local time.) edited 14:51, 2 Jul 2008
Note that a bug in 8.08 and below has that returning a local time, rather than UTC.
But you can set it to sometime in the future to enforce the overwrite (thanks, Bjorg!) edited 18:02, 25 Feb 2009