---
title: "REST - Read"
canonical: "https://help.agiloft.com/space/HELP/43714567/REST%20-%20Read"
format: markdown
---
The EWRead operation returns the encoded data of the specified record. The URL must include the ID of the record being queried.

- **Returns**: the encoded data of the record.
- **Supported Content-Type**: <span style="color: #505050">application/</span>x-www-form-urlencoded
- Accepts a URL with URL-encoded parameters and record data. For more information about general URL conventions, see [REST Interface](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43715778).

In place of the usual ID parameter, you can use $searchSQL to identify the record to update, provided that the search returns exactly one record and no more. For example, if you have a unique ext_id field in Agiloft, you can update a single record that has ext_id='a0B2c345' using `&$searchSQL=ext_id='a0B2c345'` in the URL.

## Example

Assume an instance of Agiloft is available on localhost, port 8080 and is called "Demo". The updated record can be seen in the [Update example](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43714575).

The following request is issued: 

```xml
 https://localhost:8080/ewws/EWRead?$KB=Demo&$table=Contacts.Employees&$login=admin&$password=qwerty&$lang=en&id=358 
```

The following result will be returned: 

```javascript
EWREST_full_name='John Doe';
EWREST_first_name='John';
EWREST__1576_company_name0='IBM';
EWREST_f_group_0='Service Manager';
EWREST_id='358';
EWREST__106_sw_description='Service Management Team';
EWREST__login='jdoe';
EWREST_date_updated='Dec 27 2017 04:40:24';
EWREST_type='employees';
EWREST_date_created='Dec 27 2017 04:34:38';
EWREST_rep_email='example23@example.com';
EWREST_default_approval_title='Document Approval';
EWREST_last_name='Doe';
```

## JavaScript Example

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

```java
     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 ("Opportunity"+EWREST_opportunity_name_0);        }
    }
    function main() {
        xmlhttpGet('https://localhost:8080/ewws/EWRead?$KB=Demo&$table=Contacts.Employees&$login=admin&$password=qwerty&$lang=en&id=358');
    }
```

# Error Codes

The below error codes are for EWRead only, but are not an extensive list of possible error codes. For any errors not listed here, consult the General Error Codes section of [https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43715778](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43715778).

|  |  |  |  |
| --- | --- | --- | --- |
| Error   Scenario | Type | Error Code | Error Description |
| When there is no data found for the   provided ids in the request | VALIDATION | 400 | EWWrongDataException   → no data found for id range(s) |
| When there are any error while getting related fields | VALIDATION | 500 | EWUnexpectedException → while getting related table   meta-data |

> Macro (hide-if)
> 
> #### Related articles
> 
> > Macro (contentbylabel)