Hi Team,
We are trying to attach PDF documents to both Purchase Invoices using the standard Business Central Document Attachments API.
The process consists of two steps:
Create a record in the standard documentAttachments entity.
Upload the PDF content using the attachmentContent endpoint.
The attachment record is created successfully, and the upload request returns HTTP 204 (No Content). However:
The PDF is not attached correctly to the Purchase Invoice.
An Incoming Document record is created.
Downloading the attached document results in a corrupted PDF that cannot be opened
The request body to create attachment record is
{
"fileName": "abc.pdf",
"ParentType": "Purchase Invoice",
"Parent Id": "1234-12345-2434".
}
Whereas for uploading the file content I am using PATCH method with uri as https://api.businesscentral.dynamics.com/v2.0/{tenant}/{environment}/api/v2.0/companies({companyId})/documentAttachments({attachmentId})/attachmentContent
and send the file content from SharePoint for the request body with expression as "body('Get_file_content')?['$content']".
Thank you!