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 APIIn 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"?> <dataset> <title>Mandatory – Descriptive name for the data item</title> <data> <dataitem>Read the Multiple data items section</dataitem> </data> </dataset>
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"?> <result> <success>Read note 1</success> <status_code>Read note 2</status_code> <data_id>Read note 3</data_id> </result>
- true if the request was successful, otherwise false
- For details of status codes and reason phrases, refer to the Status codes topic
- The identifier of the dataset added: refer to the #Multiple data items section
What to do next
- Adding a post
- Appending to a post
- Editing a post
- For information about status and reason codes from LabTrove, see Status codes.