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

REST - Retrieve Attachment

The EWRetrieve REST operation:

  • Returns the attached file specified by position from the named field in the record identified by the supplied key. 
  • Accepts the URL with parameters as per general URL conventions which can be viewed in the REST Interface Overview
  • Supported Content-Type: application/x-www-form-urlencoded
  • Returns the file as binary content in the body of the response via a GET or POST HTTP method. 
  • The URL must contain the identifier of the record, the name of the field to retrieve the file from and the position of the file in the field.
  • All parameters must be properly URL-encoded. 


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('http://localhost:8080/ewws/EWRetrieve?$KB=Demo&$table=someTable&$login=admin&$password=qwerty&id=1234&field=someField&filePosition=1#39;
    }

CONTENTS