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
- Download the Demo Companies and Contacts Template and save it locally.
- 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.
- Create a Scope called
companiesandcontacts
, and associate it with thedemo_companies_and_contacts
Schema in your newly created database.
The IDE
-
Create a new VS Code VoltScript Workspace folder called lab-04.
- Open Visual Studio Code.
-
From the Explorer view, click Open Folder.
-
Create a new folder in your user directory, with the name stated above.
- Select the newly created folder to open in VS Code.
atlas.json
- Download the atlas.json and save it to your
lab-04
folder. - Modify
atlas.json
value forauthors
appropriately and save it. - Run VoltScript Dependency Setup and create your
atlas-settings.json
file as you did in Lab 03a - From the Command Palette, run
VoltScript: Install Dependencies
.
VOLTSCRIPT CODE
- Download main.vss and save it to the src folder.
- Open src/main.vss and modify the script.
- Set the values for the constants
DRAPI_URL
,USER_NAME
, andUSER_PASSWORD
to the appropriate values for your environment. Ensure that the /api/v1 suffix remains forDRAPI_URL
.
- Set the values for the constants
-
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 theserverUrl
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 theDrapiServer
object, and prints out information about all of the views. It is important to note here that information returned by thegetLists
method is restricted to only theActive 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).
- The script instantiates a new
-
Return focus to the main.vss file in your VS Code editor.
- 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).
- 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.