Hi all, I need help! The API documentation shows clear examples of how to download attachments via the api (associated with bank explanations) but does not show how to upload them. The field concerned is given in the download example as a url which makes no sense for an upload since it is set by Freeagent to the location on Amazon S3 where Freeagent decides to store the attachment. Can anybody give me any pointers/code snippet? Thanks in advance.
Thanks for your question! If I understand you correctly, you’re asking for how you can upload attachments associated with bank explanations through the API. You note that our documentation on this only provides examples about how to do this using attachments that already exist in FreeAgent.
I think there is another option which will help you. The bank transaction explanations attributes shows that an attachment can have a
data component, which is a base64 encoded representation of the attribute. As indicated there, this can be up to 5MB in size. So using this you should be able to upload an attachment at the same time as the explanation.
A common gotcha working with base64 encoders like this is that the
Interestingly, I note we don’t show the
url version of the attachment attribute here in the docs. We’ll need to fix that at some point.
I hope that helps! If I’ve misunderstood your question, or you want some clarification, do let us know.
Thanks for the reply. So I am trying something like this in a post to /bank_transaction_explanations and I get 500 Internal Server error as a response - kinda hard to debug. Am I missing some fields? Many thanks in advance.
“description”: “M&S SIMPLY FOOD - ON 08 JUN///”,
“file_name”: “2017-06-08 7.50.pdf”,
“data”: “JVBERi0xLjMKJcT —— (lots and lots more in here) —— IF0gPj4Kc3RhcnR4cmVmCjQwMjE2MwolJUVPRgo=”,
“description”: “(auto upload)”,
FYI, Managed to sort this… problem was poorly formatted data. This approach does work!
Sorry to not have gotten back to you earlier. I’m glad to hear that you’ve gotten this working, and that it lets you achieve your goal. When you say the problem you had was poorly formatted data, do you mean the base64 encoded data you sent to the API?
I’m curious to understand if there’s anything we can do to improve our error messages here.
Thanks again for the question - I’m sure it’ll help others
No… it was purely my mistake!