First REST Request - Connection
This article shows how to send your first REST request to the ADOXX API for simply checking if a successful connection can be made.
The first part shows a simple unauthenticated connection request, the second part focusses on executing a token-based authenticated connection request.
Unauthenticated Connection
The simplest endpoint offered by the ADOXX API is an unauthenticated GET request to the endpoint /rest/connection
which simply tests if the REST service responds correctly.
The Java snippet below shows how to send the request.
Replace the values in angle brackets with values that fit your setup, e.g. instead of <HOST> use the host at which you access your ADOXX instance.
Click to view the code!
Loading code...
The expected outcome looks similar to the following:
Status Code: 200
Result:
REST Connection Service Evaluation invoked @ Mon Feb 22 11:38:47 CET 2021
Authenticated Connection
Except for the special unauthenticated connection endpoint, requests will always have to authenticate. To test if authenticated access is working the endpoint /rest/connection/auth
can be used.
ADOXX RESTful services support three authentication mechanisms. The Java snippet below uses Token Based Authentication. The token is generated using the Util class introduced in First REST Request - Connection.
More sophisticated authentication mechanisms are detailed in the Rest API guide.
The following Java snippet shows a simple Java class
containing a static method that creates the security token based on the passed parameters:
Click to view the code!
Loading code...
The following Java snippet shows how to use this class and send an authenticated connection request to the server:
Click to view the code!
Loading code...
The expected outcome looks similar to the following:
Status Code: 200
Result:
Authorized Access Granted @ Mon Feb 22 11:40:23 CET 2021