Step 1: GET a resource

Create a new KNIME workflow. If the KREST extension has been installed successfully you will find a new Community Nodes subcategory in you Node Repository view. The subcategory is called REST Nodes.

REST category in node repository view

Add a GET resource node to your workflow. The node has one input port and two outputs. The input port is optional. It can be used to provide a URL (this will be explained later). For now, we will enter the URL directly by good old typing.

Open the node. You will see a section called URL. Select Manual Input and enter http://127.0.0.1:6543/projects. This URL provides access to collection of projects exposed by the demo server.

GET resource dialog

Press OK and execute the node. The node will now create a request and send it to our server. Once the response returns the node execution is completed. The response is then presented in 2 ports:

  • Port 0 displays the status code, the header data and although technically not part of the response but for the sake of completeness - the URL the request has been sent to.
    Header ouput port
  • Port 1 presents the body of the response (if there is any). The representation is not processed.
    Representation output port

In the following we will describe some additional features of the node. This is not required for the tutorial. If you like, you can skip this section and proceed directly with Step 2.

As you will see when you open the response body port the output table contains only one single cell. The can be a string cell or an XML cell depending on the content type of the representation. By default, the cell type is detected automatically. If you already know the content type in advance you can tell the node to prepare a certain cell type. The advantage of this approach is that it allows you to configure successive nodes before executing the submitter. The cell type for the body representation can be selected in the dialog (in the Response representation cell type drop-down menu).

In case of a string cell, the response representation might be hard to read, since the string cell does not display line breaks. For this reason, the representation can also be displayed in a view. The view displays linebreaks and provides some basic formatting.

Representation View

As you may have noticed, there is also a section called Authentication in the dialog. Here you can add credentials for authentication purposes. There are 2 built-in methods (HTTP Basic Access and HTTP Digest Access) which both require input of a username and password. If the server requests login data and you have not provided any, you will still get the opportunity to do so during node execution. However, fill in these fields will prevent this extra step.
If you are going to use this option, make sure to activate the KNIME master key on the preferences page KNIME > Master Key. Otherwise the password will be stored unencrypted.
Next to the built-in methods, you can add own authentication methods by implementing the com.cenix.jerseyauth.custom or com.cenix.jerseyauth2.custom2 extension point, respectively. Which extension point to choose depends on your KREST version. Regard that the extensions for version 2 are not compatible with KREST version 1 and vice versa.
The default values for the used method (incl. installed custom methods) and the two built-in method fields, can be set in the Preferences.

Last but not least: You can customize other request header fields as well. There is an extra tab for this which is called Header Settings. The most prominent use case here is probably requesting a certain data format for the response via an Accept header field.
Keep in mind that even if you request certain feature a server might ignore or reject this information.

LinkedInTwitterShare