Forum Discussion
Extracting attachments from Business Central via API early 2024
Hi all
According to the API documentation, the pdf or images attached to e.g. purchase invoices can be found using /attachments endpoint. This works very well for late 2024 and 2025 invoices, but finance says an update was applied mid 2024 and all invoices before july 2024, do not have any attachments.
Also, instead of using the /puchaseInvoices endpoint, the early entries can instead be found under /generalLedgerEntries.
I have tried, what seems to be, all options, but finance can show the PDF for a posting in the system, but for some reason, it seems impossible for me to find it using the API.
In conclusion, the data (PDFs) exist, they can be found using the system but I do not know where to look when using the API.
Do anyone have a recommendation on how to proceed or solve the issue?
Thanks in advance!
Best,
Victor
1 Reply
Would suggest:
- Try Filtering by Journal or Ledger Entry
Use the /attachments endpoint with a filter like:
GET /api/v1.0/companies({id})/attachments?$filter=parentId eq {journalLineId} and parentType eq 'Journal'
Replace parentType with 'GeneralLedgerEntry' if applicable.
- Check for Incoming Documents
Older PDFs may be stored as Incoming Documents. Try querying:
GET /api/v1.0/companies({id})/incomingDocuments
Then match the sourceId or documentId with your ledger entries.
- Explore Media or MediaSet Fields
Some attachments may be stored using the Media or MediaSet data types. These aren't always exposed via /attachments, so you may need to:
- Use AL code to expose them via a custom API
- Check if the document is linked to a custom page or extension