---
title: "REST - Remove Attachment"
canonical: "https://help.agiloft.com/space/HELP/43714589/REST+-+Remove+Attachment"
format: markdown
---
> Macro (anchor)

The EWRemoveAttachment operation removes an attached file from a field in a record; <span style="color: #333333">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.</span>

- **Returns**: the number of attached files remaining in the field.
- **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).
- 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: 

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

# Error Codes

For a list of errors, 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).

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