Creating documents

Once you have created a project of your own, the next step you would like to do is to add documents to the project.

There are three ways to add documents to a project:

  1. To add a document from a pre-registered database, e.g. PubMed or PMC.
  2. To import documents from an existing project.
  3. To create a new document

This page explains the third method.

You can create a document by providing a block of text and relevant information, using one of following ways.

Using Browser GUI

  1. Go to your project page.
    • top > projects > your_project
  2. If you are logged in, you will find the create a new document menu.
    create_document_form
  3. Click the menu to open the New document dialog.
  4. Provide a block of text and relevant information, e.g. source URL. If you are not sure about the relevant information, you can just the fields blank, and click the Create document button.

Using REST API

You can use any REST client, e.g. cURL, to ‘POST’ a document to your project.

Note that most recent major programming languages have modules for REST access, and you can do the same thing using any of your favorite programming languages.

The following example shows a simple cURL command to create a new document in the project your_project:

Following is explanation of the option specification:

  • -u “your_email_address:your_password
    • Specifies your login information.
  • -d text=”This is a sample text.”
    • Specifies the text to be This is a sample text..
  • http://pubannotation.org/projects/your-project/docs.json
    • The URL for adding new entries to the document list of your project.
    • By adding the suffix .json in the end, you can get the result message in JSON.

You can also send the text in JSON:

  • -H “content-type:application/json”
    • Tells the server to interprete the body of the request as JSON.
  • -d ‘{“text”:”This is a sample text”}’
    • Tells cURL to send (by the POST method) the text in JSON.

The above examples do not specify the sourcedb and sourceid. In the case the sourcedb will be set to be @your_username, and the sourceid to be the smallest integer that does not already exist as a sourceid within the sourcedb.

If you want, you can also specify the sourcedb and the sourceid as you like. However, the sourcedb has to be prefixed with your username, e.g., sourcedb_name@your_username:

Using JSON, you can send multiple document specifications: