Adding data

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 data using the REST API

In the request string, the <action> is adddata, for example:…

The XML data that you append to the request string comprises the description of the dataset and the data items that it contains, as illustrated by the following example of the XML data for an adddata request:

<?xml version="1.0" encoding="UTF-8"?>
  <title>Mandatory – Descriptive name for the data item</title>        
    <dataitem>Read the Multiple data items section</dataitem> 

Multiple data items

A dataset comprises one or more files containing the same data but in different formats. For example, the main dataitem might be in a machine-readable format and the second dataitem might be in a human-readable format, such as .JPG.


  • main - identifies the principal dataitem in the dataset: main can take any value.
  • type - can be url, inline orfile: if type="url", LabTrove obtains the data by reference to the URL; if type="inline", LabTrove obtains the data by uploading the file. type="file" The file can be uploaded as multipart/form-data file
  • ext - identifies the file type by its extension.


  <dataitem type="url" ext="pdf" filename="THESIS.pdf">http://url.of.file/THESIS.pdf</dataitem>                
  <dataitem type="inline" ext="txt" main="1" filename="yourData.txt"># base64 encoded#</dataitem>         
  <dataitem type="file" ext="txt" filename="yourData.txt"># the multipart file variable name #</dataitem>         

When you upload data inline, convert the content of the file to base64 encoded format and supply the resulting string as the body of the dataitem. LabTrove stores the data with the name yourData.txt. There is a file size limit of approximately 500KB when uploading data 'inline'.

Understanding the response

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>
  <data_id>Read note 3</data_id>


  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 dataset added: refer to the #Multiple data items section

What to do next