Hi Dynamics community!
I am having an issue with Sales Order attachments via API (through Postman).
I can successfully create an attachment object for a given sales order like so:
POST api.businesscentral.dynamics.com/.../attachments
with the body containing:
{
"parentId" : "Sales Order ID",
"fileName": "TEST.pdf",
"parentType": "Sales Order"
}
However, if I now try to add the attachment content like so (with IF-MATCH for the odata tag):
PATCH api.businesscentral.dynamics.com/.../attachments(parentId=salesOrderId,id=attachmentId)/attachmentContent
I receive an error message:
{
"error": {
"code": "BadRequest_NotFound",
"message": "The number of keys specified in the URI does not match number of key properties for the resource 'Microsoft.NAV.attachment'."
}
}
And in Business Central the Sales Order in question still shows no attachment.
Conversely, if I upload an attachment to the SO and try to retrieve it via the API, this SO seems to have no attachments at all.
Somewhere there is a disconnect between what I’m doing on BC, and what I’m doing via the API.
Any ideas or suggestions would be greatly appreciated!