Attachments
This section describes the API of the expense resource. It covers only listing
, updating
and destructing
actions. If you would like to create a new attachment, please visit Uploads section.
Allowed file extentions
image/jpeg
image/jpg
image/gif
image/png
image/tiff
application/pdf
application/xml
text/xml
Example of Attachment
List attachments
List all attachments of an expense. It will return a collection informations containing the total of record, total_pages, current_page and a set of attachments objects.
Parameters
page: | integer |
per_page: | integer limit to 100 |
Definition
GET https://app.rexpense.com/api/v1/expenses/:expense_id/attachments
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/expenses/1/attachments \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
Show an attachment
This request shows the attachment complete information. It will return an attachment object representation.
Parameters
id: | integer required |
Definition
GET https://app.rexpense.com/api/v1/expenses/:expense_id/attachments/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/expenses/1/attachments/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK
Response Example Failure
HTTP 404 Record Not Found
Update an attachment
This request updates attachments informations. It will return an attachment object representation.
There are two ways to update a attachment: partially or fully. If you'd like to change just one or
a few attributes, you have to use the HTTP method PATCH
. If you use the HTTP method PUT
, you'll have to
pass all attributes of the attachment.
Parameters
file: | string |
description: | string |
The file
parameter must be an URL of the attachment. This URL may be achieve following
the steps in Uploads section.
Definition
PUT/PATCH https://app.rexpense.com/api/v1/expenses/:expense_id/attachments/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/expenses/1/attachments/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"description":"Travel to Paris"}'
Response Example Success
HTTP 200 OK
Response Example Failure
HTTP 422 Unprocessable Entity
Destroy an attachment
This request destroy an attachment. It will return an empty body.
Parameters
id: | integer required |
Definition
DELETE https://app.rexpense.com/api/v1/expenses/:expense_id/attachments/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/expenses/1/attachments/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 204 No Content