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

REST - Remove Attachment

The EWRemoveAttachment operation removes an attached file from a field in 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 removed.

  • Returns: the number of attached files remaining in the field.
  • Supported Content-Typeapplication/x-www-form-urlencoded
  • Accepts a URL with URL-encoded parameters and record data. For more information about general URL conventions, see REST Interface.
  • Additionally, the URL must contain the identifier of the record, the name of the field to remove the file from, and the position of the file in the field. 

JavaScript Example

Here is an example for a JavaScript-based client that opens 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/EWRemoveAttachment?$KB=Demo&$table=someTable&$login=admin&$password=qwerty&id=1234&field=someField&filePosition=1#39;
    }