Page tree

REST - Retrieve Attachment

The EWRetrieve operation returns an attached file from a record; the file is identified by its position in the field, in case multiple files are attached, and the URL must specify the record ID, the name of the field, and the position of the file to be retrieved. 

  • Returns: the file content in the body of the response, using a GET or POST HTTP method.
  • Supported Content-Type: the Content-Type used when attaching the original file.
  • Accepts a URL with URL-encoded parameters and record data. For more information about general URL conventions, see REST Interface.

JavaScript Example

Here is an example of 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") {
            alert ("A file has been returned");
        }
    }
    function main() {
        xmlhttpGet('https://localhost:8080/ewws/EWRetrieve?$KB=Demo&$table=someTable&$login=admin&$password=qwerty&id=1234&field=someField&filePosition=1#39;
    }