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 documents 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 PubAnnotation with 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. Enter a block of text in the Text field.
  5. Enter relevant information, e.g. source URL. If you are not sure about the relevant information, you can just leave them blank.
  6. 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.
    • You can omit the password part. Then, cURL will ask you for the password.
  • -F text=”This is a sample text.”
    • Specifies the text to be This is a sample text..
    • If you want, you can tell it to read the text from a file, by prefixing the file name with the symbol ‘<’,
      • e.g., -F “text=<a_file_name”.
  • -F sourcedb=”TestDocs”
    • Specifies the sourcedb of the text to be TextDocs.
    • It is optional.
  • -F sourceid=”1”
    • Specifies the sourceid of the text to be 1.
    • It is optional.
  • https://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 response 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 such a 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: