View or Download Attachments from an Invoice
Your accounts payable user wants to view or download an invoice attachment. They get all the attachments of an invoice and use the self URI of the specific attachment.
Example URL
Here's an example of the resource URL to retrieve all the attachments:
GET
fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments
cURL Command
https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments
Example Response
Here's an example of the response body in JSON format:
{
"items": [
{
"AttachedDocumentId": 300100177565182,
"LastUpdateDate": "2018-09-05T09:19:33.411+00:00",
"LastUpdatedBy": "AP_SUPV_OPERATIONS",
"FileName": "REST Invoice related attachment.txt",
...
"links": [
{
"rel": "self",
"href": "https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments/00020000000EACED00057708000110F0847B15FE0000000EACED00057708000110F0847B15FD",
"name": "attachments",
"kind": "item"
},
{
"rel": "canonical",
"href": "https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments/00020000000EACED00057708000110F0847B15FE0000000EACED00057708000110F0847B15FD",
"name": "attachments",
"kind": "item"
},
...
]
},
...
],
"count": 10,
"hasMore": false,
"limit": 25,
"offset": 0,
"links": [
{
"rel": "self",
"href": "https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments",
"name": "attachments",
"kind": "collection"
}
]
}
A hash key of InvoiceId
and AttachedDocumentId
identifies an attachment.
Here's the cURL command that uses the hash key in the self URI to retrieve the attachment:
curl -i -u "<username>:<password>" -H "Content-Type: application/json" -X GET https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments/00020000000EACED00057708000110F0847B15FE0000000EACED00057708000110F0847B15FD
Example Response
Here's an example of the response body in JSON format:
{
"items": [
{
"AttachedDocumentId": 300100177565182,
"LastUpdateDate": "2018-09-05T09:19:33.411+00:00",
"LastUpdatedBy": "AP_SUPV_OPERATIONS",
"FileName": "REST Invoice related attachment.txt",
...
"links": [
{
"rel": "self",
"href": "https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments/00020000000EACED00057708000110F0847B15FE0000000EACED00057708000110F0847B15FD",
"name": "attachments",
"kind": "item"
},
{
"rel": "canonical",
"href": "https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments/00020000000EACED00057708000110F0847B15FE0000000EACED00057708000110F0847B15FD",
"name": "attachments",
"kind": "item"
},
...
]
}
]
}
Additional Steps to Download the Attachment
Your user can:
- Use the
FileContents
enclosure for programmatic downloads. It appears as a link for the attachment when performing a GET action on the Attachments resource. - The link returns a stream. This includes
attachment details such as
FileName
and the Mime Type, likeUploadedFileContentType
, for correct handling of the result for any destination.
Here's an example of the link that is returned:
"links": [
...
{
"rel": "enclosure",
"href": " https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/invoices/300100177565180/child/attachments/00020000000EACED00057708000110F0847B15FE0000000EACED00057708000110F0847B15FD /enclosure/FileContents",
"name": "FileContents",
"kind": "other"
}
]