Page tree
Skip to end of metadata
Go to start of metadata

REST - Select

The EWSelect REST operation:

  • Performs a select on the specified table, implementing the Select operation of the REST interface.
  • Accepts the URL with parameters as per general URL conventions which can be viewed in the REST Interface Overview. Additionally, the URL must contain the where clause of the SELECT query to be performed. All parameters must be properly URL-encoded. 
  • This returns the number of records found, and an encoded data list of record IDs, if any were found.

Only one SQL statement is accepted per call. The API automatically and transparently applies security filters to prevent unauthorized access to information. 

These SQL queries operate on the database level and should be written in terms of dbname column names as visible in the in the Table Wizard in the GUI. Some values for high-level complex field types may have very different representation from what is seen in the GUI. For example, see REST Interface - GetChoiceLineId for the special handling of choice values.


The SQL query supplied should only include the 'where' clause from a construct similar to: 

select primary-key-field-name from table-name where ...

This returns the number of records found, and an encoded data list of record ID, if any were found.

It is possible to limit the number of records returned through means available to the underlying database used by your instance of Agiloft . For example "limit 0,200" for MySQL will limit the number of the returned records to 200.

It is not possible currently to influence the sequence in which records are returned. They are returned in the effectively arbitrary default order returned by the underlying database. If you wish to impose a sort order on the record sequence, consider using a EWSearch call instead. This will allow you to use a saved search to define a sort order.

Example 1

Assume an instance of  Agiloft is available on localhost, port 8080 and is called "Demo". List the Service Request records assigned to 'Ralph Knowles'.

The following request is issued: 

http://localhost:8080/ewws/EWSelect?$KB=Demo&$login=admin&$password=qwerty&$table=helpdesk_case&$lang=en&where=assigned_person='Ralph Knowles'

If there are no records found, the following result will be returned: 

EWREST_id_length = '0';
The following result will be returned in the case of three records being found: 
EWREST_id_length = '3';
EWREST_id_0 = '150';
EWREST_id_1 = '169';
EWREST_id_2 = '325';

Example 2

Assume an instance of  Agiloft is available on localhost, port 8080 and Demo KB. List the records with summaries containing word 'new’ (summary like '%new%').

The following request is issued: 

http://localhost:8080/ewws/EWSelect?$KB=Demo&$login=admin&$password=qwerty&$table=helpdesk_case&$lang=en&where=summary%20like%20%27%25new%25%27&%24

If there are no records found, the following result will be returned: 

EWREST_id_length = '0'; 

The following result will be returned in the case of seven records being found: 

EWREST_id_length = '7';
EWREST_id_0 = '145';
EWREST_id_1 = '147';
EWREST_id_2 = '148';
EWREST_id_3 = '149';
EWREST_id_4 = '151';
EWREST_id_5 = '298';
EWREST_id_6 = '318';

Here is an example for a JavaScript-based client that invokes the REST interface via AJAX: 

function xmlhttpGet (strURL) {
        var xmlHttpReq=false;
        var self=this;
        // Mozilla/Safari
        if (window.XMLHttpRequest) {
            try {
                netscape.security.PrivilegeManager.
enablePrivilege("UniversalBrowserRead");
            } catch (e) {
                alert("Permission UniversalBrowserRead denied.");
            }
            self.xmlHttpReq=new XMLHttpRequest();
        }// IE
        else if (window.ActiveXObject) {
            self.xmlHttpReq=new ActiveXObject("Microsoft.xmlHTTP");
        }
        self.xmlHttpReq.open('GET', strURL, true);
        self.xmlHttpReq.onreadystatechange=requestComplete;
        self.xmlHttpReq.send(null);
    }
    function requestComplete() {
        if (xmlHttpReq.readyState==4||xmlHttpReq.readyState=="complete") {
            eval (self.xmlHttpReq.responseText);
            alert ("Id of new ticket"+EWREST_id);
        }
    }
    function main() {
        xmlhttpGet('
http://localhost:8080/ewws/EWSelect?$KB=Demo&$login=admin&$password=qwerty&$table=helpdesk_case&$lang=en&where=summary%20like%20%27%25new%25%27&%24');
    } 

CONTENTS