Page tree

REST - Attach

The EWAttach operation attaches a file to a field in a record; the file is passed in the body of the request, and the URL must specify the record ID, the name of the field, and the file name to assign to the file. 

  • Returns: the total number of files attached in the specified field of the record.
  • Supported Content-Type: multipart/form-data
  • 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 attach the file to and the file name to use. The file content is passed in the body of the request. 

Browsers do not support sending PUT requests. This REST operation is intended for the use of application clients. If you need to attach a file from a browser, use the regular POST requests with EWCreate or EWUpdate operations, and specify enctype="multipart/form-data" in the browser HTML form.

Example

Assume an instance of  Agiloft is available on localhost, port 8080 and is called "Demo". Attach a file to the field "someField" in record 1234 of table "someTable" with a file name as testfile.zip.

The request has to be issued via the PUT HTTP method where the body contains the content of the file to be attached. 

https://localhost:8080/ewws/EWAttach?$KB=Demo$table=someTable&$login=admin&$password=qwerty&id=1234&field=someField&fileName=testfile.zip

The following result will be returned when the file is attached: 

 EWREST_someField.length='1';
Example code
<form method="post" action="https://demo.agiloft.com/ewws/EWCreate" enctype="multipart/form-data">
<input name="$KB" value="Demo" />
<input name="$table" value="case" />
<input name="$lang" value="en" />
<input name="$login" value="admin" />
<input name="$password" value="qwerty" />
<input type="file" name="inbound_attachments"/>
<input type="submit" value="submit" />
</form>

CONTENTS