Skip to main content Skip to navigation

Editing page content

Editing the content of a page is exactly the same as creating a page, but uses a HTTP PUT method instead of a POST, and is sent to the URL for the single Atom representation of the page you want to modify. Setting the <title>, <content> or any <sitebuilder:...> elements will override their current values, so this can be used to modify the properties of the page as well.

In its simplest form of modifying the content of the page, we only need to send the <content> element, but we can also set the <sitebuilder:edit-comment> element to put a comment in the edit history of the page describing our edit:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sitebuilder="http://go.warwick.ac.uk/elab-schemas/atom">
  <content type="html">
    &lt;h2&gt;Hello World!&lt;/h2&gt;
    &lt;p&gt;Here is my newly created page&lt;/p&gt;
    &lt;p&gt;This is an extra line in the modified content of the page.&lt;/p&gt;
  </content>
  <sitebuilder:edit-comment>Added an extra line of text using APP</sitebuilder:edit-comment>
</entry>

Saving this as editpage.atom, we can send it via cURL to modify the page:

mat@augustus:~$ curl -i -X PUT --data-binary @editpage.atom -H 'Content-Type: application/atom+xml' -u cuscav
   "https://sitebuilder.warwick.ac.uk/sitebuilder2/edit/atom/atom.htm?page=/fac/sci/chemistry/mynewpage&type=single"
Enter host password for user 'cuscav':

HTTP/1.1 200 OK
Date: Tue, 22 Mar 2011 10:47:44 GMT
Server: Penny
Content-Type: application/atom+xml;charset=ISO-8859-1
Content-Length: 1344
Vary: User-Agent

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:sitebuilder="http://go.warwick.ac.uk/elab-schemas/atom">
  <title>Here is my edited page</title>
  <link rel="collection" 
    href="https://sitebuilder.warwick.ac.uk/sitebuilder2/edit/atom/atom.htm?page=/fac/sci/chemistry/mynewpage&type=list" />
  <link rel="edit" 
    href="https://sitebuilder.warwick.ac.uk/sitebuilder2/edit/atom/atom.htm?page=/fac/sci/chemistry/mynewpage&type=single" />
  <link rel="alternate" 
    href="http://www2.warwick.ac.uk/fac/sci/chemistry/mynewpage" />
  <id>urn:uuid:094d43ed2eb4e006012edd22205e7f97</id>
  <content type="html">
    &lt;h2&gt;Hello World!&lt;/h2&gt;
    &lt;p&gt;Here is my newly created page&lt;/p&gt;
    &lt;p&gt;This is an extra line in the modified content of the page.&lt;/p&gt;
  </content>
  <author>
    <name>Mathew Mannion</name>
  </author>
  <updated>2011-03-22T10:35:24Z</updated>
  <published>2011-03-22T10:35:24Z</published>
  <sitebuilder:page-name>mynewpage</sitebuilder:page-name>
  <sitebuilder:searchable>false</sitebuilder:searchable>
  <sitebuilder:visible>false</sitebuilder:visible>
  <sitebuilder:deleted>false</sitebuilder:deleted>
  <sitebuilder:span-rhs>false</sitebuilder:span-rhs>
  <sitebuilder:description>A test of the ATOM representation of a page</sitebuilder:description>
  <sitebuilder:keywords>api tests, atom</sitebuilder:keywords>
</entry>  

The response is identical to a creation except that there is no Location header (since the URL is already correct in the PUT) and the response is a 200 OK to confirm the operation is complete.