How to automatically grab all my FreeAgent data?

Any widely available hosting scripting language like Shell, PHP, Python…

Now I’m trying to use “curl” and assembly a shell script that has an array
of curl commands each getting one XML entry. But I have some problem with
the “Access Token”: I dont understand how to generate it from FA Developer
Dashboard…

I’m reading here:
https://dev.freeagent.com/docs/using_curl

Walter

To get token is described in freeagent API docs!

For the code: You need to go to Google spreadsheets, create a new
spreadsheet and add a script from there. Then running the script inside the
spreadsheet will work.

I is partial as it creates a var with all data. You can go on from there,
google apps script has a sort of database function you can use, or use it
to put all data in a spreadsheet (export to xls or csv is simple).

See google apps script docs for lots of examples and a start a script
tutorial. I am not a developer at all but can do pretty much everything I
want with GAS.

Riël

thank you for your suggestion: I wasn’r even aware of Google Script. You
open me a new world. Very interesting…

I appreciate if you could give a little more help: the code you provided
is probably partial… I’d need also the function to get the TOKEN… And
trying to run your sample I got an error:

“TypeError: Impossibile chiamare il metodo “getActiveSheet” di null.
(linea 5)”

on the line:

"var sheet = ss.getActiveSheet();

Thank you for any help.

Walter


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/-/9KfBx-8NqCwJ.

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.

Getting completely crazy. I tried any form of curl… Then got some PHP
sample but it doest work, or maybe there was some error in the server
configuration… It’s crazy a server must be involved in such this thing.

With API v1 was very easy, just matter of curl commands like this:

curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/company/users >users.xml

curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/contacts >contacts.xml

curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/invoices >invoices.xml

Is there any way to accomplish the same with just some script commands?

Walter

Craig

I gave a look at this Jetterbit I didnt’t know. Yes probably it could help,
your company does exactly what I want to do. The problem is such tool is
very expensive and enterprise oriented. There must be an easier way, just
some chain of command lines…

Walter

Thank you, now I’m starting to understand…

By the way I find quicker to get all my information using curl this way:

TOKEN=
curl “https://api.freeagent.com/v2/invoices?page=$i&per_page=100
-H "Authorization: Bearer $TOKEN "
-H “Accept: application/xml”
-H “Content-Type: application/xml”
-X GET >>invoices.xml

Now the problem is you must paginate to get all your data…

Walter

Hi Walter,

My company uses a program called Jitterbit to call the API every 15 mins or
so to download all aspects of FreeAgent and load the data into SQL. We then
use Tableau to query and visualise the data.

If you want more info send me an email at craig.bloodworth [at]
theinformationlab.co.uk

CraigOn 28 Dec 2012 17:55, “Ossowalt” wmacorig@gmail.com wrote:

I need to perform a supposed to be very easy task: get out all my
FreeAgent data into a my SQL database in order to do some custom reporting.

I see this new Oauth but not easy to understand and implement for my basic
need.

Could please someone point me to a sample script that get all my FreeAgent
entities in a readable local format like CSV or XML or other?

What I wanted to do is to run automatically once a day such script from an
hosted cloud server ( like GoDaddy or other ) , copy all my FreAgent data
(all tables, all records, all fields) into some MySql database and then use
on it some reporting tool like Zoho Report, Jasper or other to build some
custom analysis on my data.

Please can someone help me?
Thank you.

Walter


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/-/t28d9Ke822gJ.
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.

Riël

thank you for your suggestion: I wasn’r even aware of Google Script. You
open me a new world. Very interesting…

I appreciate if you could give a little more help: the code you provided is
probably partial… I’d need also the function to get the TOKEN… And
trying to run your sample I got an error:

“TypeError: Impossibile chiamare il metodo “getActiveSheet” di null. (linea
5)”

on the line:

"var sheet = ss.getActiveSheet();

Thank you for any help.

Walter

Hi Walter,

Thankfully at one point Jitterbit were a lot more open than than they are
now and have a free community edition:
http://sourceforge.net/projects/jitterbit/files/jitterbit-community/3.0.0/

There’s a server platform and a client application to install but once you
get used to it it’s really useful. I’ve even used it to download tweets via
the Twitter search API.

Have fun!

CraigOn Mon, Dec 31, 2012 at 11:15 AM, Ossowalt wmacorig@gmail.com wrote:

Craig

I gave a look at this Jetterbit I didnt’t know. Yes probably it could
help, your company does exactly what I want to do. The problem is such tool
is very expensive and enterprise oriented. There must be an easier way,
just some chain of command lines…

Walter


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/-/nf5zp-v2UGcJ.

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.

Prospect House
The Green
Slingsby
York
YO62 4AA
(01653) 627 275
07790885747

I like to use Google Apps Script, it is so convenient running it in the
cloud. Anyway, I think it is like javascript. I use these basic lines when
I want to use freeagent data:

Use some variables. type = the data you want, like projects, contacts,
invoices etc.

Change [TOKEN] in your OAUTH token.

the returned freeAgentData is an array of all data.

function freeagentGet(type, options) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();

var type = “projects”; // I have the variables to test, you can pass them
when calling the function ofcourse
var options = “?per_page=100”;

var response =
UrlFetchApp.fetch(“https://api.freeagent.com/v2/”+type+options,
{
headers: {
“Authorization”: “Bearer [TOKEN]”, “Accept”: “application/json”,
“contentType”: “application/json”}
} );

var freeAgentData = Utilities.jsonParse(response.getContentText()); //
return freeAgentData;
}

function freeagentPost(type, payload) {

var options =
{
“method” : “post”,
“payload” : payload,
“contentType” : “application/json”,
“headers” : {“Authorization”: “Bearer [TOKEN]”, “Accept”:
“application/json”}
};

var response = UrlFetchApp.fetch(“https://api.freeagent.com/v2/”+type,
options);
return response;
}Op maandag 31 december 2012 19:34:56 UTC+1 schreef Ossowalt het volgende:

Getting completely crazy. I tried any form of curl… Then got some PHP
sample but it doest work, or maybe there was some error in the server
configuration… It’s crazy a server must be involved in such this thing.

With API v1 was very easy, just matter of curl commands like this:

curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/company/users >users.xml

curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/contacts >contacts.xml

curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/invoices >invoices.xml

Is there any way to accomplish the same with just some script commands?

Walter