Uploading a statement

Hi,

Uploading a statement through the API is slightly different to other
requests in that it’s submitted as a url-encoded form post rather than as
JSON or XML. The only field that should be submitted is the statement field
which should contain the URL encoded file that you wish to upload. As the
docs at https://dev.freeagent.com/docs/bank_transactions say, an OXF format
is strongly preferred.

Regards,
Harry MillsOn Tue, Apr 2, 2013 at 7:04 AM, binay.kumar@webequator.com wrote:

Hi,

I want to know what are the data fields to send for upload a bank
statement, Freeagent does not mention in Doc
please brief me about uploading a bank statement.

Thanks

On Monday, July 23, 2012 3:07:12 PM UTC+5:30, Graeme Boyd wrote:

Hi James,

The data is sent essentially as a form parameter. Include the statement
data as a url encoded parameter “statement”, don’t convert it to JSON or
XML.

For example:

curl -H “Authorization: Bearer XXXXXXXXX”
-H “Accept: application/json”
–data-urlencode statement@statement.csv
-X POST
https://api.freeagent.com/v2/bank_transactions/statement?
bank_account=https://api.**freeagent.com/v2/bank_**accounts/123https://api.freeagent.com/v2/bank_transactions/statement?bank_account=https://api.freeagent.com/v2/bank_accounts/123

If you’re not familiar with the statement@statement.csv above, from the
Curl docs:

“name@filename
This will make curl load data from the given file (including any
newlines), URL-encode that data and pass it on in the
POST. The name part gets an equal sign appended, resulting in
name=urlencoded-file-content. Note that the name is
expected to be URL-encoded already.”

The same will work for OFX statements. Another potential caveat is to
watch what headers you’re sending the server. Many other API calls require
the Content-Type to be set to application/xml or application/json, but in
this case that will probably prevent the upload from being understood. In
my above example, curl is setting the Content-Type
to application/x-www-form-**urlencoded transparently.

Kind regards,

Graeme

On 20 July 2012 20:23, James Lawrence jlaw...@googlemail.com wrote:

Hi there, according to the API documentation it should be possible to
upload a statement in OFX or CSV format ( https://dev.freeagent.com/**
docs/bank_transactions#upload-a-bank-account-statement-to-a-
certain-bank-accounthttps://dev.freeagent.com/docs/bank_transactions#upload-a-bank-account-statement-to-a-certain-bank-account).
Unfortunately after playing around with a few hours, I can’t work out how
to send the “statement” data.

Is it sent as JSON/XML, if so then as what type? (I attempted sending it
as JSON as a byte[] and that failed), or is it sent as HTTP form data?

I’d be glad of any advice. Many thanks!


You received this message because you are subscribed to the Google
Groups “FreeAgent API” group.
To view this discussion on the web visit https://groups.google.com/d/**
msg/freeagent_api/-/**RD3PaZrJXAwJhttps://groups.google.com/d/msg/freeagent_api/-/RD3PaZrJXAwJ
.

To post to this group, send email to freeag...@googlegroups.com**.
To unsubscribe from this group, send email to freeagent_ap…@**
googlegroups.com.
For more options, visit this group at http://groups.google.com/**
group/freeagent_api?hl=enhttp://groups.google.com/group/freeagent_api?hl=en
.


Graeme Boyd
Senior Software Engineer

Web. freeagent.com http://www.freeagent.com/ Blog. freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/**freeagentapp http://facebook.com/freeagentapp

40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to freeagent_api+unsubscribe@googlegroups.com.
To post to this group, send email to freeagent_api@googlegroups.com.
Visit this group at http://groups.google.com/group/freeagent_api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Hi James,

The data is sent essentially as a form parameter. Include the statement
data as a url encoded parameter “statement”, don’t convert it to JSON or
XML.

For example:

curl -H “Authorization: Bearer XXXXXXXXX”
-H “Accept: application/json”
–data-urlencode statement@statement.csv
-X POST \

https://api.freeagent.com/v2/bank_transactions/statement?bank_account=https://api.freeagent.com/v2/bank_accounts/123

If you’re not familiar with the statement@statement.csv above, from the
Curl docs:

“name@filename
This will make curl load data from the given file (including any newlines),
URL-encode that data and pass it on in the
POST. The name part gets an equal sign appended, resulting in
name=urlencoded-file-content. Note that the name is
expected to be URL-encoded already.”

The same will work for OFX statements. Another potential caveat is to
watch what headers you’re sending the server. Many other API calls require
the Content-Type to be set to application/xml or application/json, but in
this case that will probably prevent the upload from being understood. In
my above example, curl is setting the Content-Type
to application/x-www-form-urlencoded transparently.

Kind regards,

GraemeOn 20 July 2012 20:23, James Lawrence jlaw9018@googlemail.com wrote:

Hi there, according to the API documentation it should be possible to
upload a statement in OFX or CSV format (
https://dev.freeagent.com/docs/bank_transactions#upload-a-bank-account-statement-to-a-certain-bank-account).
Unfortunately after playing around with a few hours, I can’t work out how
to send the “statement” data.

Is it sent as JSON/XML, if so then as what type? (I attempted sending it
as JSON as a byte[] and that failed), or is it sent as HTTP form data?

I’d be glad of any advice. Many thanks!


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To view this discussion on the web visit
https://groups.google.com/d/msg/freeagent_api/-/RD3PaZrJXAwJ.

To post to this group, send email to freeagent_api@googlegroups.com.
To unsubscribe from this group, send email to
freeagent_api+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/freeagent_api?hl=en.

Graeme Boyd
Senior Software Engineer

Web. freeagent.com http://www.freeagent.com/ Blog. freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/freeagentapp

40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774

Hi Tom,

The code I pasted previously works for me. The error you’re seeing means
that the statement data is not reaching the code which starts the import.
It could be that the front end server is stripping it. I see you’ve
opened a support ticket for this. Could you attach the file you’re trying
to upload to the ticket?

Kind regards,

GraemeOn 14 August 2012 15:05, Tom Hodder tom@limepepper.co.uk wrote:

On Monday, July 23, 2012 10:37:12 AM UTC+1, Graeme Boyd wrote:

Hi James,

The data is sent essentially as a form parameter. Include the statement
data as a url encoded parameter “statement”, don’t convert it to JSON or
XML.

So following your advice above I am doing the following;

curl -S --trace-ascii -
-H “Authorization: OAuth XXX”
-H “Accept: application/json”
–data-urlencode statement@test.ofx
-X POST \

https://api.sandbox.freeagent.com/v2/bank_transactions/statement?bank_account=https://api.sandbox.freeagent.com/v2/bank_accounts/75

and I get the following error;
{“errors”:{“error”:{“message”:“Statement data not found”}}}== Info:
Closing connection #0

The trace output indicates the body of the POST is indeed an encoded OFX
file;

0000: HTTP/1.1 100 Continue
=> Send data, 16384 bytes (0x4000)
0000: statement=%0D%0AOFXHEADER%3A100%0D%0ADATA%3AOFXSGML%0D%0AVERSION
0040: %3A102%0D%0ASECURITY%3ANONE%0D%0AENCODING%3AUSASCII%0D%0ACHARSET
0080: %3A1252%0D%0ACOMPRESSION%3ANONE%0D%0AOLDFILEUID%3ANONE%0D%0ANEWF

The bank account definitely exists… Any suggestions?

I’ve tested the same test.ofx file against the manual upload in the
sandbox using the browser…


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To view this discussion on the web visit
https://groups.google.com/d/msg/freeagent_api/-/LvU1Z0aBdEwJ.

To post to this group, send email to freeagent_api@googlegroups.com.
To unsubscribe from this group, send email to
freeagent_api+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/freeagent_api?hl=en.

Graeme Boyd
Senior Software Engineer

Web. freeagent.com http://www.freeagent.com/ Blog. freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/freeagentapp

40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774