# Uploading a statement

**URL:** <https://api-discuss.freeagent.com/t/uploading-a-statement/97>\
**Category:** Uncategorized\
**Created:** [2 April 2013 11:19 UTC](https://api-discuss.freeagent.com/t/uploading-a-statement/97 "2013-04-02T11:19:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harry\_Mills](https://api-discuss.freeagent.com/user_avatar/api-discuss.freeagent.com/harry_mills/32/46_2.png) [@Harry\_Mills](https://api-discuss.freeagent.com/u/Harry_Mills)\
**Post date:** [2 April 2013 11:19 UTC](https://api-discuss.freeagent.com/t/uploading-a-statement/97/1 "2013-04-02T11:19:26Z")

</div>

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 [FreeAgent Developer Dashboard](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](mailto: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?](https://api.freeagent.com/v2/**bank_transactions/statement?)\*\*  
> > bank\_account=[https://api](https://api).\*\*[freeagent.com/v2/bank\_\*\*accounts/123](http://freeagent.com/v2/bank_**accounts/123)[https://api.freeagent.com/v2/bank\_transactions/statement?bank\_account=https://api.freeagent.com/v2/bank\_accounts/123](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,
> > 
> > Graeme
> > 
> > On 20 July 2012 20:23, James Lawrence [jlaw...@googlemail.com](mailto: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/](https://dev.freeagent.com/)\*\*  
> > > docs/bank\_transactions#upload- **a-bank-account-statement-to-a-**  
> > > certain-bank-account[https://dev.freeagent.com/docs/bank\_transactions#upload-a-bank-account-statement-to-a-certain-bank-account](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/](https://groups.google.com/d/)\*\*  
> > > msg/freeagent\_api/-/\*\*RD3PaZrJXAwJ[https://groups.google.com/d/msg/freeagent\_api/-/RD3PaZrJXAwJ](https://groups.google.com/d/msg/freeagent_api/-/RD3PaZrJXAwJ)  
> > > .
> > > 
> > > To post to this group, send email to [freeag...@googlegroups.com](mailto:freeag...@googlegroups.com)\*\*.  
> > > To unsubscribe from this group, send email to freeagent\_ap…@\*\*  
> > > [googlegroups.com](http://googlegroups.com).  
> > > For more options, visit this group at [http://groups.google.com/](http://groups.google.com/)\*\*  
> > > group/freeagent\_api?hl=en[http://groups.google.com/group/freeagent\_api?hl=en](http://groups.google.com/group/freeagent_api?hl=en)  
> > > .
> > 
> > –  
> > Graeme Boyd  
> > Senior Software Engineer
> > 
> > Web. [freeagent.com](http://freeagent.com) [http://www.freeagent.com/](http://www.freeagent.com/) Blog. [The FreeAgent Blog - FreeAgent](http://freeagent.com/blog)  
> > Twitter. @freeagent [https://twitter.com/#!/freeagent](https://twitter.com/#!/freeagent) Facebook.  
> > [Facebook](http://facebook.com/**freeagentapp) [http://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](mailto:freeagent_api+unsubscribe@googlegroups.com).  
> > To post to this group, send email to [freeagent\_api@googlegroups.com](mailto:freeagent_api@googlegroups.com).  
> > Visit this group at [http://groups.google.com/group/freeagent\_api?hl=en](http://groups.google.com/group/freeagent_api?hl=en).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Graeme\_Boyd](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@Graeme\_Boyd](https://api-discuss.freeagent.com/u/Graeme_Boyd)\
**Post date:** [23 July 2012 09:37 UTC](https://api-discuss.freeagent.com/t/uploading-a-statement/97/2 "2012-07-23T09:37:12Z")

</div>

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](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](mailto:jlaw9018@googlemail.com) wrote:

> Hi there, according to the API documentation it should be possible to  
> upload a statement in OFX or CSV format (  
> [FreeAgent Developer Dashboard](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](https://groups.google.com/d/msg/freeagent_api/-/RD3PaZrJXAwJ).
> 
> To post to this group, send email to [freeagent\_api@googlegroups.com](mailto:freeagent_api@googlegroups.com).  
> To unsubscribe from this group, send email to  
> [freeagent\_api+unsubscribe@googlegroups.com](mailto:freeagent_api+unsubscribe@googlegroups.com).  
> For more options, visit this group at  
> [http://groups.google.com/group/freeagent\_api?hl=en](http://groups.google.com/group/freeagent_api?hl=en).

Graeme Boyd  
Senior Software Engineer

Web. [freeagent.com](http://freeagent.com) [http://www.freeagent.com/](http://www.freeagent.com/) Blog. [The FreeAgent Blog - FreeAgent](http://freeagent.com/blog)  
Twitter. @freeagent [https://twitter.com/#!/freeagent](https://twitter.com/#!/freeagent) Facebook.  
[FreeAgent | Edinburgh](http://facebook.com/freeagentapp)

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

---

<div class="post-metadata">

**Author:** ![Graeme\_Boyd](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@Graeme\_Boyd](https://api-discuss.freeagent.com/u/Graeme_Boyd)\
**Post date:** [15 August 2012 14:10 UTC](https://api-discuss.freeagent.com/t/uploading-a-statement/97/3 "2012-08-15T14:10:25Z")

</div>

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](mailto: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](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](https://groups.google.com/d/msg/freeagent_api/-/LvU1Z0aBdEwJ).
> 
> To post to this group, send email to [freeagent\_api@googlegroups.com](mailto:freeagent_api@googlegroups.com).  
> To unsubscribe from this group, send email to  
> [freeagent\_api+unsubscribe@googlegroups.com](mailto:freeagent_api+unsubscribe@googlegroups.com).  
> For more options, visit this group at  
> [http://groups.google.com/group/freeagent\_api?hl=en](http://groups.google.com/group/freeagent_api?hl=en).

Graeme Boyd  
Senior Software Engineer

Web. [freeagent.com](http://freeagent.com) [http://www.freeagent.com/](http://www.freeagent.com/) Blog. [The FreeAgent Blog - FreeAgent](http://freeagent.com/blog)  
Twitter. @freeagent [https://twitter.com/#!/freeagent](https://twitter.com/#!/freeagent) Facebook.  
[FreeAgent | Edinburgh](http://facebook.com/freeagentapp)

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