Redirected from Deki/API Reference/POST:pages/{pageid}/contents
Was this page helpful?

POST:pages/{pageid}/contents

  • You do not have permissions to view this page - please try logging in.

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
authenticatebool?Force authentication for request (default: false)
commentstring?the edit comment
edittimestringthe edit timestamp (yyyyMMddHHmmss or yyyy-MM-ddTHH:mm:ssZ)
importtimestring?If this is an import, the edit timestamp of the imported content (yyyyMMddHHmmss or yyyy-MM-ddTHH:mm:ssZ)
languagestring?the page language (default: determine culture from parent)
overwritebool?New page revision is created when no changes are detected when overwrite is true (default: false)
redirectsint?If zero, do not follow page redirects.
reltoint?Page used for path normalization (default: none)
reltopathstring?Page used for path normalization. Ignored if relto parameter is defined. (default: none)
sectionint?the section number. If zero, append as a new section
tidy{remove, convert}?Determines if invalid content is converted to text or removed (default: 'convert')
titlestring?the display title (default: use existing title or determine 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

C# Samples

 

Curl Samples

 

PHP Samples

 

Other Code Samples

 

Note

The edittime parameter has to be supplied when updating a page!

Was this page helpful?
Tag page
Viewing 4 of 4 comments: view all
What format does edittime have to be?

UPDATE - Looks to be yyyymmddhhmmss. (And use UTC time, not local time.) edited 06:51, 2 Jul 2008
Posted 12:18, 1 Jul 2008
{{ Date.format( Date.Now, "yyyyMMddhhmmss" ) }}

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 10:02, 25 Feb 2009
Posted 22:13, 24 Feb 2009
Note: for the Uri paramete, pageid, if you use a name, you have to explicitly double-encode it with the XUri.Double.EncodeSegment method, documented here:
http://developer.mindtouch.com/en/ref/dream/MindTouch.Dream/XUri/DoubleEncodeSegment
See the C# example for more information.
Posted 08:03, 31 Mar 2011
Any ideas on how I can specify a template to use for the new page and pass in form data using this approach? (POSTing using a jquery ajax call btw) Seems like it only works when the entire page content is known/generated/retrieved in advance..
Posted 19:54, 4 Apr 2011
Viewing 4 of 4 comments: view all
You must login to post a comment.

Copyright © 2011 MindTouch, Inc. Powered by