Editing a post

From LabTrove Documentation
Jump to: navigation, search

Owing to the evolution of LabTrove Notebooks from a blog-based system, some internal variables do still use the term blog.

Editing a post using the REST API

In the request string, the <action> is editpost, for example:
http://www.ourexperiment.org/api/rest/editpost/uid/<uid>

The XML data that you append to the request string comprises the mandatory information for the post, the content, and optional items such as metadata and attachments. For further information, read the notes associated with the following example of the XML data for an editpost request:

<?xml version="1.0" encoding="UTF-8"?> 
<post> 
  <id>Mandatory - Read note 1</id>     
  <title>Mandatory</title>
  <section>Mandatory - Read note 2</section>        
  <author>                
    <username>Mandatory - Read note 3</username>
  </author>        
  <content>                
    Mandatory - Read note 4
  </content>        
  <datestamp>Optional – Read note 5</datestamp> 
  <blog_sname>The short name of the target {{Blog}}</blog_sname>        
  <metadata> 
    <key>Optional – Read note 6</key>
  </metadata>        
  <attached_data>
    <data>Optional – Read note 7</data> 
  </attached_data>
  <edit_reason>Mandatory</edit_reason> 
</post>

Notes:

  1. To find out how to obtain the identifier of the post that you want to edit, refer to the Understanding the response section in the Adding a post topic.
  2. Use either an existing Section value or a new value if you want to create a new Section
  3. The username must have a system account for the Trove and must have the appropriate authorisation level for the Notebook
  4. The post content can include BBCode markup
  5. If you provide a datestamp, it must conform to the RFC-822 date-time specification
  6. Replace key with the name of the metadata key to which you want to give a value: you can use either an existing key or create a new key. For example, to assert that this post is about Test 42, use <test>42</test>
  7. You can attach data to a post only if the data item has been uploaded previously. To find out how to obtain the identifier of the data item, refer to the Adding data topic.

For example, to attach the data item with data_id 5, use:

<data type="local">5</data>

To attach multiple data items, include a <data> element for each item. Note that local is the only type option available with the current implementation.

Understanding the response

LabTrove returns a response in XML format, structured as follows:

<?xml version="1.0" encoding="UTF-8"?>  
<result>      
  <success>Read note 1</success>
  <status_code>Read note 2</status_code>
  <post_id>Read note 3</post_id>
  <post_info>Read note 4</post_info>
</result>

Notes:

  1. true if the request was successful, otherwise false
  2. For details of status codes and reason phrases, refer to the Status codes topic
  3. The identifier of the post supplied in the <id> element of the request
  4. URI for the xml version of the added post

What to do next


Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox