Attachments

Dear group,

Do I understand that at the moment the only way to retrieve attachment
data via the API is to download an XML representation of >all< of the
attachment meta and actual data each and every time?

Say I have an expense, bank account entry or bill and I wish to
retrieve the associated attachment. How would this be possible if I
don’t have the attachment’s ID?

Also the attachment ID is not returned in the attachments XML so even
if I wanted to requery the attachment, I can’t (unless I requery all
the attachment data from scratch).

Alternatively, would it be possible to have the attachment ID appended
as an element to the Expense, Bank Account Entry or Bill - rather than
the other way around? (So one expense has one attachment. One bank
account entry has one attachment. All the attachment_id’s can be read
from the Expense or Bank Account Entry or Bill classes).

In summary: As I’m totally unable to retrieve singular attachments one
at a time (as I do not ever know the attachment’s ID) I am forced into
retrieving ALL the attachments (including data) in the one event. This
is likely to be catastrophic for performance on my software as well as
on FreeAgent’s servers.

Can it be possible to handle the attachments in the same way as
clients, invoices, time slips, etc?

If not, can it be possible to retrieve all the attachments WITHOUT the
data but WITH the attachment ID’s? Therefore I can request all the
META data for every single attachment in one go, but without the
Base64 encoded string content - and instead request the attachment by
ID as required?

Many thanks,

Mike

Bingo :slight_smile:

And you know what else? The balance sheet balances too :slight_smile:

All in all, my favourite FreeAgent Central release so far!

[Edit]

The id will probably be added as a field rather than an attribute, to
remain consistent with the rest of the API, e.g.

<?xml version="1.0" encoding="UTF-8"?> 1234 application/x-pdf filename.pdf 74661 A description 123456 Expense

Thanks Mike.

First point: The /attachments resource does stipulate that a
element containing base64 encoded binary data for each attachment will
be returned.

Fixed

Second point: The /expenses resource also needs fleshing out in the
docs.

I’ll update this once the release has gone out.

Regarding requirements - yes, almost all the boxes are ticked. I’d
like to be able to GET the Bank Account Entry resource too please then
I’ll be 95% there :slight_smile:

We should have this for you really soon.

Hi Mike

Thanks very much for the feedback.

Do I understand that at the moment the only way to retrieve attachment
data via the API is to download an XML representation of >all< of the
attachment meta and actual data each and every time?

No binary data is sent when accessing the ‘/attachments/’ resource.
You access the binary data directly via the temporary URL which is
specified in the ‘Location’ header of the HTTP response.

Also the attachment ID is not returned in the attachments XML so even
if I wanted to requery the attachment, I can’t (unless I requery all
the attachment data from scratch).

The ID is indeed missing from the Attachment XML – a rather large
oversight. We will ensure this is present in tonight’s software
update, so the new XML will look something like:

<?xml version="1.0" encoding="UTF-8"?> application/x-pdf filename.pdf 74661 A description 123456 Expense

Alternatively, would it be possible to have the attachment ID appended
as an element to the Expense, Bank Account Entry or Bill - rather than
the other way around? (So one expense has one attachment. One bank
account entry has one attachment. All the attachment_id’s can be read
from the Expense or Bank Account Entry or Bill classes).

This is already the case. If you query a specific Expense resource
which has an attachment, for example, the XML response will have the
following format:

<?xml version="1.0" encoding="UTF-8"?> 2008-10-21T00:00:00Z 3 Years External Hard Drive 1 0 Computer Hardware -130.87 true 123456 0 0.0 0.4 0.4 17.5 0.0 7 application/x-pdf filename.pdf 74661 A description 1234 Expense

(Note: the ‘id’ attribute on in the above example will
only be present after tonight’s update)

Once the update to add the id has been released, do you think the
Attachments API will fulfill you basic requirements? Let me know what
you think

Cheers, Olly

Hi Olly,

This is absolutely fantastic news. In which case, the documentation
needs updating, see below:

First point: The /attachments resource does stipulate that a
element containing base64 encoded binary data for each attachment will
be returned.

Second point: The /expenses resource also needs fleshing out in the
docs.

However, your reply is absolutely perfect and spot-on. If it’s already
there, I’ll take a look. I should be making my first proof of concept
“receipts” tonight at the latest. I’ll let you know how it goes.

Regarding requirements - yes, almost all the boxes are ticked. I’d
like to be able to GET the Bank Account Entry resource too please then
I’ll be 95% there :slight_smile:

Best,

Mike

Mike

Just to let you know that the id field is now included in Attachment
API queries.

Cheers, OllyOn Oct 22, 3:18 pm, Olly o...@freeagentcentral.com wrote:

Thanks Mike.

First point: The /attachments resource does stipulate that a
element containing base64 encoded binary data for each attachment will
be returned.

Fixed

Second point: The /expenses resource also needs fleshing out in the
docs.

I’ll update this once the release has gone out.

Regarding requirements - yes, almost all the boxes are ticked. I’d
like to be able to GET the Bank Account Entry resource too please then
I’ll be 95% there :slight_smile:

We should have this for you really soon.