Hi @Ewa_Lipinska,
I am trying to attach a pdf file with a bill using api, It’s working fine without attachment.
My attachment object is as below. I am using C#.
faAttachment attachment = new faAttachment();
attachment.url = “https://api.freeagent.com/v2/attachments”;
attachment.content_src = “D:\114471598187481919.PDF”;
attachment.content_type = “application/pdf”;
attachment.file_name = “11.PDF”;
It shows me error message which is “Invalid attachment data”.
Please help me regarding the same as soon as possible.
Hello Nishit
Thanks for your post, one of the engineering team will respond to you early next week.
In future, if you’re able to create posts without tagging individual engineers that would be very much appreciated (and may actually get your query answered quicker if that engineer is away).
Thanks very much.
Stuart McEwan
Core Services:API Product Manager
Ah, the attachment.content_src
here is invalid. Your client needs to provide the data in the response. So, in this case, provide a data
attribute that contains BASE64 encoded data in the request:
"bill": {
"contact": "{{url}}/contacts/1",
"reference": "Bill ref 01",
"dated_on": "2015-10-17",
"due_on": "2015-11-17",
"category": "{{url}}/categories/285",
"total_value": "300",
"sale_tax_rate": "20",
"attachment": {
"data": "iVBORw0KGgoAAAANSUhEUgAAAgAAA...",
"content_type": "image/png",
"file_name": "receipt.png",
"description": "photo of the receipt"
}
}
This example comes from our postman example export, found at https://github.com/fac/postman-freeagent-api-collection with instructions on how to use it.
Hope that helps!
Phil