In this example we will call a REST endpoint to return a series of rows that we want to use to populate a dropdown in our Volt app. I have chosen to use a free service, the Brewery Open API. Using Link we can create a service that will enable this content to be pulled into our Volt applications.
Create Link Connector
Launch the HCL Link admin page, http://localhost:9990/login (In my deployment I changed the port).
Make sure that you are working with the “_app_volt” project and “deploy_action=true” in the url. I set a bookmark that has the relevant url suffix, http://localhost:9990/workspace?_p=60a4454d8f331f240bfea01b&app=_app_volt&deploy_action=true.
Close the popup dialog that shows when the page first loads.
On the bottom of the screen click “Connections”, and then “New”.
5. Select “REST” from the list of available types and click “Next”. (Note: REST and REST API are not equivalent, REST API is a legacy connector and should not be used).
6. Enter a meaningful name and description for the Connection.
The name will appear in the HCL Volt Service Catalog dropdown, therefore it should be something that is easily recognized and understood by those that will use it.
Create an Action
7. The Connection now appears in the Connection List. Expand the Connection List, hover over “Breweries (REST)”, click on the 3 vertical dots and click “New Action”.
8. We are create an action where the Brewery API is the source. Select “Source” for the Action Type and click Next.
9. In the Properties section:
i) Select “Generic” for the Configuration Mode.
ii) Provide the URL for the REST endpoint, which is https://api.openbrewerydb.org/breweries.
iii) Select “GET” for the Method.
iv) Select “None” for the Authentication.
v) Enter “Content-Type=application/json” for the Headers. This is to enforce the return to be JSON.
vi) The rest of the properties can be left to their default values.
vii) Click Next.
10. In the Schema section, select New, enter a name (i.e. Breweries), and click “Generate”. The Schema Type dropdown will show you the structure of the REST response. The value that you select here will change the output of the service. In this case we want the entire JSON object to be returned, therefore select “JSON” as the Schema Type and click Next.
11. In the Identification section provide a meaningful name and description.
This detail will be shown in the Volt UI and used to identify the service. Note: As a service is updated in Link, Volt will report the version of that service and the last time that it was updated. It is important to note that all previous versions of a Link service can be executed, therefore updating a Link service will not break any apps that are using it.
12. When you click OK, as long as you have “deploy_action=true” in the URL, a popup will appear and show the progress of the Action being deployed.
13. The Connection and Action will now appear in Volt. There is a task that runs every 6 minutes to update the connectors/catalogs from Link to Volt. You may also restart the Domino HTTP task if you want the Link catalog to appear in Volt immediately. Note: Changes to actions will appear immediately in Volt.
14. You are now ready to use the Link Connector/Action!
Setup Service in Volt
15. Create a table on your form canvas and add to it a few fields. Add a button to the form which will be used to call the Brewery service. In the field properties, under “Service” click the “On click, call a service“ checkbox. Click “Add/Edit Service Configuration”
Note: You may also create the service from the Settings tab. Under Services select the form that will contain the service. Click Add Service Configuration.
16. Select “Select from Service Catalog”, select “Breweries (REST)” from the Service Catalog dropdown, select “List Breweries” and click Next.
17. Click Next as there are no Inputs for this service.
18. Map a few of the outputs (i.e. Name, Type, City, or Country) to the fields of the table.
19. Save and Preview the form. When the form loads you should see all the colors appear in the dropdown.
20. You are all done! You have successfully pulled data from a REST endpoint into your Volt application from HCL Link.
Add Comment