Add Attachments to AP Invoice using REST API


Recently we were working on a VBCS UI to create AP invoices. Part of that requirement was that users should be able to attach documents as well.
Since it was from a VBCS UI we were looking for a pure REST solution as we did not want to build any wrappers using OIC or any other middleware.
Thankfully Oracle API for Payables Invoice supports it out of the box.
So below is a sample payload which accepts the base64
contents of the file.
- URL :
/fscmRestApi/resources/latest/invoices
- Method :
POST
{
"InvoiceNumber": "TEST",
"InvoiceCurrency": "USD",
"InvoiceAmount": 123,
"InvoiceDate": "2022-10-10",
"BusinessUnit": "Sample BU",
"Supplier": "SupplierName",
"SupplierSite": "SiteName",
"Description": "Test Desc",
"InvoiceGroup": "Test Invoice Group",
"PaymentMethod": "Electronic",
"PayGroup": "Domestic",
"attachments": [
{
"Type": "File",
"FileName": "REST Invoice related attachment.zip",
"Title": "REST Invoice related attachment",
"Description": "REST Invoice related attachment",
"Category": "From Supplier",
"FileContents": "UEsDBBQAAAAIABCInEgIHJSKCgAAAAgAAAAIAAAAdGVzdC50eHRzTEpWCEktLgEAUEsBAh8AFAAAAAgAEIicSAgclIoKAAAACAAAAAgAJAAAAAAAAAAgAAAAAAAAAHRlc3QudHh0CgAgAAAAAAABABgAW4FRYEGh0QEBIE9gQaHRAckeCWBBodEBUEsFBgAAAAABAAEAWgAAADAAAAAAAA=="
}
],
"invoiceLines": [
{
"LineNumber": 1,
"LineAmount": 123,
"DistributionCombination": "00.11.22.33.44.55.66",
"AccountingDate": "2022-10-12"
}
]
}
The above payload is to create invoice with attachments. But if you are looking for only attaching content then you can just use the below format.
URL :
/fscmRestApi/resources/latest/invoices/{invoicesUniqID}/child/attachments
Method :
POST
{
"Type": "File",
"FileName": "REST Invoice related attachment.zip",
"Title": "REST Invoice related attachment",
"Description": "REST Invoice related attachment",
"Category": "From Supplier",
"FileContents": "UEsDBBQAAAAIABCInEgIHJSKCgAAAAgAAAAIAAAAdGVzdC50eHRzTEpWCEktLgEAUEsBAh8AFAAAAAgAEIicSAgclIoKAAAACAAAAAgAJAAAAAAAAAAgAAAAAAAAAHRlc3QudHh0CgAgAAAAAAABABgAW4FRYEGh0QEBIE9gQaHRAckeCWBBodEBUEsFBgAAAAABAAEAWgAAADAAAAAAAA=="
}
PS : If you want to learn how to get the base64
contents of a file uploaded in VBCS check out this blog.
Subscribe to my newsletter
Read articles from Satish Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Satish Kumar
Satish Kumar
The views, thoughts, and opinions expressed belong solely to the author, and not necessarily to the author's employer, organization, committee or other group or individual.