Replace an Attachment to an Expense Report

PUT /expense-reports​/{id}/attachments/{attachment_id} — Use this method to replace an attachment to the expense report with the specified internal ID.

Important:

This method can only be used to replace an attachment directly associated with the expense report. It cannot be used for workspace document associated with the expense report either to replace the workspace document or to associate a different workspace document in its place.

Note:

If the Attachment Thumbnail and Attachment Viewer feature is enabled for your OpenAir account, a thumbnail is generated automatically when you add an attachment of a supported format. The file_name must be included in the request and must include a supported file extension. For more information about the Attachment Thumbnail feature, including supported file format and filename extensions, see Attachment Viewer and Attachment Thumbnail.

Parameters

Path parameters

Path parameter

Required / Optional

Description

Type

{id}

Required

The internal ID of the expense report.

integer

{attachment_id}

Required

The internal ID of the attachment.

integer

Query string parameter

Path parameter

Required / Optional

Description

Type

expand

Optional

A comma-separated list of attributes available for expansion. The comma-separated list may include spaces (or %20 in the URL encoded string).

Note:

The expand value must contain only attributes referencing a supported object type. If return_object is set to any value other than 0 (zero), and the comma-separated list includes at least one attribute that is not available for expansion, the request fails — an error is returned and the object is not added or updated. For more information about attributes available for expansion and supported object types, see Available Expansions and Supported Object Types.

string

fields

Optional

A comma-separated list of attributes to include in the response. If not specified, the response includes all attributes for the attachment returned. For the Attachment object properties, see Attachment object properties.

string

filterSetId

Optional

The internal ID of the filter set to be applied.

  • When specified, the request is successful only if the action is available when the specified filter set is active in OpenAir. The filter set with the specified internal ID must exist and must be associated with the user who authorized the application as per the access token.

  • Otherwise and by default, the primary filter set associated with the user who authorized the application is applied.

integer

return_object

Optional

If set to any value other than 0 (zero), the response will return the attachment created. Otherwise, the response will include only the internal ID of the attachment created.

Boolean

Request body

This method accepts the following content type:

Content-Type header

Body

multipart/form-data

Form data with the following key-value pair:

  • file — The file to be uploaded. The file and file metadata will be used to replace the existing Attachment object with a new Attachment object.

Response definitions

A successful request returns a JSON object with the following properties:

Property

Description

data

An array containing one of the following:

  • The Attachment object created, if the return_object parameter was set to any value other than 0 (zero) in the request. The object includes all the attributes specified using the fields if included in the request.

  • An object with only the internal ID of the attachment created.

See Returned Data. For the Attachment object properties, see Attachment object properties.

included

An array of expanded objects, if the expand parameter was set in the request.

See Referenced Objects and Expansion.

meta

An object containing information about objects referenced by internal ID in the data array (object type and internal ID). Only returned if the return_object parameter was set to any value other than 0 (zero) in the request.

See Referenced Objects and Expansion.

message

A string containing a brief message about the status of your request — e.g. “Success”.

A failed request returns a JSON object with the following properties:

Property

Description

message

A string containing a brief message about the status of your request.

Sample request

            PUT /rest/v1/expense-reports​/237/attachments/ HTTP/1.1
Host: company-id.app.openair.com
Content-Type: multipart/form-data boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Authorization: Bearer <OAuth2_access_token>

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"

@C:\Users\mcollins\Desktop\2020-12-08_18-47-31.png
----WebKitFormBoundary7MA4YWxkTrZu0gW 

          

In the example, <OAuth2_access_token> is the OAuth 2.0 access token obtained for the client application connecting to OpenAir. See Authentication.

Sample response

            {
   "data": [
      {
         "id": 4982
      }
   ],
   "message": "success"
}