Skip to content

Lab 04 - Reading from a DRAPI Request

Duration 30 min

What you will learn

You will learn how to connect to an HCL Domino REST API Scope and pull information from a view using VoltScript Code and DrapiVSE.

Prerequisites

  • Lab 03b completed
  • Familiarity with creating a Domino Database from a Template
  • Familiarity with creating a Scope and Schema in the HCL Domino REST API

Steps

DRAPI SETUP

  1. Download the Demo Companies and Contacts Template and save it locally.
  2. Create a New Database instance from the template on the HCL Domino server upon which your HCL Domino REST API is installed, and set the ACL appropriately for your DRAPI instance.
  3. Create a Scope called companiesandcontacts, and associate it with the demo_companies_and_contacts Schema in your newly created database.

The IDE

  1. Create a new VS Code VoltScript Workspace folder called lab-04.

    1. Open Visual Studio Code.
    2. From the Explorer view, click Open Folder.

      VoltScript Language Support

    3. Create a new folder in your user directory, with the name stated above.

    4. Select the newly created folder to open in VS Code.

atlas.json

  1. Download the atlas.json and save it to your lab-04 folder.
  2. Modify atlas.json value for authors appropriately and save it.
  3. Run VoltScript Dependency Setup and create your atlas-settings.json file as you did in Lab 03a
  4. From the Command Palette, run VoltScript: Install Dependencies.

VOLTSCRIPT CODE

  1. Download main.vss and save it to the src folder.
  2. Open src/main.vss and modify the script.
    • Set the values for the constants DRAPI_URL, USER_NAME, and USER_PASSWORD to the appropriate values for your environment. Ensure that the /api/v1 suffix remains for DRAPI_URL.
  3. As you review the script, you will find the DrapiVSE Documentation to be a useful reference.

    • The script instantiates a new DrapiServer object, and then sets the serverUrl property.
    • It then logs into the server using the appropriate credentials, and then prints the user's information to the console.
    • The script then gets the appropriate DrapiRequest from the DrapiServer object, and prints out information about all of the views. It is important to note here that information returned by the getLists method is restricted to only the Active Views you configured during the DRAPI SETUP portion of this lab.
    • The script then prints out all of the entries in the contactsByCompany view; which at this point should be an empty array (no entries).
  4. Return focus to the main.vss file in your VS Code editor.

  5. Press Ctrl+Shift+P (Cmd+Shift+P on Mac), then select VoltScript: Save & Run Script. (You can start typing "VoltScript" to filter the available commands).
  6. Press the Enter key to confirm your input (no script arguments are necessary).

Success

You have successfully connected to an HCL Domino REST API Instance, passed authentication, and queried information from a specific Scope and printed it out to the console -all with just a few lines of VoltScript Code.

Review

This gives you an idea of a day in the life of a VoltScript developer. You will use VoltScript Dependency Manager to avoid having to copy and paste dependencies around. You can retrieve data from a remote data store using various VoltScript Extensions, and retrieve information from them.

The code for the lab is available on GitHub.

Looking Forward

In Lab 05, you will learn to use the VoltScriptJsonConverter to process raw JSON data into JSON document records.

In Lab 06, you will use the JSON document records to add Customer and Contact records to your database. This will provide you with populated content for use with a Volt Foundry Integration Service you will create in a later lab.