Adding 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.

Adding a post using the REST API[edit]

In the request string, the <action> is addpost, for example:<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 addpost request:

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


  1. Use either an existing Section value or a new value if you want to create a new Section.
  2. The username must have a system account for the Trove and must have the appropriate authorisation level for the Notebook.
  3. The post content can include BBCode markup.
  4. If you provide a datestamp, it must conform to the RFC-822 date-time specification.
  5. Replace key with the name of the metadata key to which you are giving 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>.
  6. 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 </tt> element for each item. Note that <tt>local</tt> is the only <tt>type</tt> option available with the current implementation.

Understanding the response[edit]

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

<?xml version="1.0" encoding="UTF-8"?>  
  <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>


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

What to do next[edit]