MindTouch Developer Center > MindTouch Deki > API Reference > POST:pages/{pageid}/contents

Overview

public. Update contents of a page

Uri Parameters
NameTypeDescription
pageidstringeither an integer page ID, "home", or "=" followed by a double uri-encoded page title
Query Parameters
NameTypeDescription
abort{never, modified, exists}?specifies condition under which to prevent the save; default is never
commentstring?the edit comment
edittimestringthe edit timestamp
languagestring?the page language (default: determine culture from parent)
redirectsint?If zero, do not follow page redirects.
sectionint?the section number. If zero, append as a new section
titlestring?the display title (default: determine title from page path)
xpathstring?identifies the portion of the page to update; this parameter is ignored if section is specified
Return Codes
NameValueDescription
BadRequest400Invalid input parameter or request body
Forbidden403Update access to the page is required
NotFound404Requested page could not be found
Ok200The request completed successfully

Message Format

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>

Implementation Notes

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.

Code Samples

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>
Tag page
Viewing 1 of 1 comments: view all
What format does edittime have to be?

UPDATE - Looks to be yyyymmddhhmmss. (And use UTC time, not local time.) edited 14:51, 2 Jul 2008
Posted 20:18, 1 Jul 2008
Viewing 1 of 1 comments: view all
You must login to post a comment.
Powered by MindTouch Deki v.8.08