Not able to get last created invoice detail

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice from
freeAgent,
actually my client is habitual of doing direct entries in FreeAgent, and
due to which my Invoice reference according to my database is already exist
there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about that…

Now its a live project.

Murray,

You are right, but the header parameters passes by us, and how would i know
the no of pages or total no of records to pass in header.
Please can u give an example codeOn Friday, 6 June 2014 14:46:30 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for letting me know your use case. When creating an invoice if the
reference is omitted the next invoice reference will automatically be used
as documented. (https://dev.freeagent.com/docs/invoices#create-an-invoice)

As discussed in some other threads we do have a feature request to allow
sorting and ordering in the API. If you aren’t aware we recently introduced
a FreeAgent API Trello board to give better visibility of what we’re
working on and to better gauge what the most in-demand features are. You’ll
notice that sorting and ordering is one of the cards on the board.

For future reference the pagination information is included in the Link
header of the response (
https://dev.freeagent.com/docs/introduction#pagination)

Regards,
Murray Summers

On Friday, June 6, 2014 9:51:11 AM UTC+1, vipul Kumar wrote:

Hi Murray,

I was trying to get invoices by using your suggestion, but there is a
lack of information or i am unable to find a way, to get the pagination
links,
I have try https://api.freeagent.com/v2/invoices and its giving all the
25 invoices, but how i would know that how many invoices are there at
server,
I am not getting the prev and next link in query, or the last page number
or the total records (How can i get these to get a single latest invoice
ref. no.)

Please help…
thanks

On Thursday, 5 June 2014 17:16:47 UTC+5:30, Murray Summers wrote:

Vipul,

Glad the reply was helpful and sorry for not fully answering your
question.

Could you clarify whether you want to get the last invoice created or
the last invoice reference? How were you planning on using the invoice
reference? Are you aware that there are different types of invoice
referencing schemes that FreeAgent support
http://www.freeagent.com/support/kb/invoicing/invoice-numbering-schemes so
depending on how you plan to use the last invoice reference depends on the
correct way to get the last invoice reference.

The best way to get the last invoice created is the following:

  1. Make a GET request to https://api.freeagent.com/v2/invoices.
  2. Inspect the pagination headers to find the last page url (
    https://dev.freeagent.com/docs/introduction).
  3. Make a further GET request to
    https://api.freeagent.com/v2/invoices?page=X&per_page=Y replacing X
    and Y with the right values.
  4. The last created invoice should be the last invoice in the return
    JSON array.

Regards,
Murray Summers

On Thursday, June 5, 2014 6:57:25 AM UTC+1, vipul Kumar wrote:

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather
that is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?

On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this
should be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent
open or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice
from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent,
and due to which my Invoice reference according to my database is already
exist there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about
that…

Now its a live project.

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather that
is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this should
be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent open
or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice
from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent, and
due to which my Invoice reference according to my database is already exist
there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about that…

Now its a live project.

Vipul,

You are indeed correct that you pass header parameters when making your
requests, however when you get a response from us we include response
headers, one of which is the Link header for pagination. The link header
looks like the following:

Link:
https://api.freeagent.com/v2/invoices?page=4&per_page=50; rel=“prev”,
https://api.freeagent.com/v2/invoices?page=6&per_page=50; rel=“next”,
https://api.freeagent.com/v2/invoices?page=1&per_page=50; rel=“first”,
https://api.freeagent.com/v2/invoices?page=10&per_page=50; rel=“last”

The total number of pages can be found out by inspecting the link
associated to rel=“last”. In the above example it would be:

https://api.freeagent.com/v2/invoices?page=10&per_page=50; rel=“last”

The number of records can then be calculated by doing some maths.

May I suggest you use the Google OAuth2 Playground and make some requests
so you can see the full response with the headers?

Cheers,
Murray SummersOn Friday, June 6, 2014 10:49:26 AM UTC+1, vipul Kumar wrote:

Murray,

You are right, but the header parameters passes by us, and how would i
know the no of pages or total no of records to pass in header.
Please can u give an example code

On Friday, 6 June 2014 14:46:30 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for letting me know your use case. When creating an invoice if the
reference is omitted the next invoice reference will automatically be used
as documented. (https://dev.freeagent.com/docs/invoices#create-an-invoice
)

As discussed in some other threads we do have a feature request to allow
sorting and ordering in the API. If you aren’t aware we recently introduced
a FreeAgent API Trello board to give better visibility of what we’re
working on and to better gauge what the most in-demand features are. You’ll
notice that sorting and ordering is one of the cards on the board.

For future reference the pagination information is included in the Link
header of the response (
https://dev.freeagent.com/docs/introduction#pagination)

Regards,
Murray Summers

On Friday, June 6, 2014 9:51:11 AM UTC+1, vipul Kumar wrote:

Hi Murray,

I was trying to get invoices by using your suggestion, but there is a
lack of information or i am unable to find a way, to get the pagination
links,
I have try https://api.freeagent.com/v2/invoices and its giving all
the 25 invoices, but how i would know that how many invoices are there at
server,
I am not getting the prev and next link in query, or the last page
number or the total records (How can i get these to get a single latest
invoice ref. no.)

Please help…
thanks

On Thursday, 5 June 2014 17:16:47 UTC+5:30, Murray Summers wrote:

Vipul,

Glad the reply was helpful and sorry for not fully answering your
question.

Could you clarify whether you want to get the last invoice created or
the last invoice reference? How were you planning on using the invoice
reference? Are you aware that there are different types of invoice
referencing schemes that FreeAgent support
http://www.freeagent.com/support/kb/invoicing/invoice-numbering-schemes so
depending on how you plan to use the last invoice reference depends on the
correct way to get the last invoice reference.

The best way to get the last invoice created is the following:

  1. Make a GET request to https://api.freeagent.com/v2/invoices.
  2. Inspect the pagination headers to find the last page url (
    https://dev.freeagent.com/docs/introduction).
  3. Make a further GET request to
    https://api.freeagent.com/v2/invoices?page=X&per_page=Y replacing X
    and Y with the right values.
  4. The last created invoice should be the last invoice in the
    return JSON array.

Regards,
Murray Summers

On Thursday, June 5, 2014 6:57:25 AM UTC+1, vipul Kumar wrote:

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather
that is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?

On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this
should be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent
open or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created
Invoice from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent,
and due to which my Invoice reference according to my database is already
exist there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about
that…

Now its a live project.

Hi Murray,

I was trying to get invoices by using your suggestion, but there is a lack
of information or i am unable to find a way, to get the pagination links,
I have try https://api.freeagent.com/v2/invoices and its giving all the 25
invoices, but how i would know that how many invoices are there at server,
I am not getting the prev and next link in query, or the last page number
or the total records (How can i get these to get a single latest invoice
ref. no.)

Please help…
thanksOn Thursday, 5 June 2014 17:16:47 UTC+5:30, Murray Summers wrote:

Vipul,

Glad the reply was helpful and sorry for not fully answering your question.

Could you clarify whether you want to get the last invoice created or the
last invoice reference? How were you planning on using the invoice
reference? Are you aware that there are different types of invoice
referencing schemes that FreeAgent support
http://www.freeagent.com/support/kb/invoicing/invoice-numbering-schemes so
depending on how you plan to use the last invoice reference depends on the
correct way to get the last invoice reference.

The best way to get the last invoice created is the following:

  1. Make a GET request to https://api.freeagent.com/v2/invoices.
  2. Inspect the pagination headers to find the last page url (
    https://dev.freeagent.com/docs/introduction).
  3. Make a further GET request to
    https://api.freeagent.com/v2/invoices?page=X&per_page=Y replacing X
    and Y with the right values.
  4. The last created invoice should be the last invoice in the return
    JSON array.

Regards,
Murray Summers

On Thursday, June 5, 2014 6:57:25 AM UTC+1, vipul Kumar wrote:

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather that
is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?

On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this
should be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent
open or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice
from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent,
and due to which my Invoice reference according to my database is already
exist there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about
that…

Now its a live project.

Vipul,

Thanks for letting me know your use case. When creating an invoice if the
reference is omitted the next invoice reference will automatically be used
as documented. (https://dev.freeagent.com/docs/invoices#create-an-invoice)

As discussed in some other threads we do have a feature request to allow
sorting and ordering in the API. If you aren’t aware we recently introduced
a FreeAgent API Trello board to give better visibility of what we’re
working on and to better gauge what the most in-demand features are. You’ll
notice that sorting and ordering is one of the cards on the board.

For future reference the pagination information is included in the Link
header of the response
(https://dev.freeagent.com/docs/introduction#pagination)

Regards,
Murray SummersOn Friday, June 6, 2014 9:51:11 AM UTC+1, vipul Kumar wrote:

Hi Murray,

I was trying to get invoices by using your suggestion, but there is a lack
of information or i am unable to find a way, to get the pagination links,
I have try https://api.freeagent.com/v2/invoices and its giving all the
25 invoices, but how i would know that how many invoices are there at
server,
I am not getting the prev and next link in query, or the last page number
or the total records (How can i get these to get a single latest invoice
ref. no.)

Please help…
thanks

On Thursday, 5 June 2014 17:16:47 UTC+5:30, Murray Summers wrote:

Vipul,

Glad the reply was helpful and sorry for not fully answering your
question.

Could you clarify whether you want to get the last invoice created or the
last invoice reference? How were you planning on using the invoice
reference? Are you aware that there are different types of invoice
referencing schemes that FreeAgent support
http://www.freeagent.com/support/kb/invoicing/invoice-numbering-schemes so
depending on how you plan to use the last invoice reference depends on the
correct way to get the last invoice reference.

The best way to get the last invoice created is the following:

  1. Make a GET request to https://api.freeagent.com/v2/invoices.
  2. Inspect the pagination headers to find the last page url (
    https://dev.freeagent.com/docs/introduction).
  3. Make a further GET request to
    https://api.freeagent.com/v2/invoices?page=X&per_page=Y replacing X
    and Y with the right values.
  4. The last created invoice should be the last invoice in the return
    JSON array.

Regards,
Murray Summers

On Thursday, June 5, 2014 6:57:25 AM UTC+1, vipul Kumar wrote:

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather
that is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?

On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this
should be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent
open or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice
from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent,
and due to which my Invoice reference according to my database is already
exist there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about
that…

Now its a live project.

Hi Murray,

I need to get the last invoice reference no. for making new invoice with
next sequence invoice reference no. and This is a long way you are
suggesting,
Can’t we get the invoices, as “OrderBy” =>“DESC”.
It would be really helpful for me, as am using this functionality in
back-end process, and will make my page very slow.On Thursday, 5 June 2014 17:16:47 UTC+5:30, Murray Summers wrote:

Vipul,

Glad the reply was helpful and sorry for not fully answering your question.

Could you clarify whether you want to get the last invoice created or the
last invoice reference? How were you planning on using the invoice
reference? Are you aware that there are different types of invoice
referencing schemes that FreeAgent support
http://www.freeagent.com/support/kb/invoicing/invoice-numbering-schemes so
depending on how you plan to use the last invoice reference depends on the
correct way to get the last invoice reference.

The best way to get the last invoice created is the following:

  1. Make a GET request to https://api.freeagent.com/v2/invoices.
  2. Inspect the pagination headers to find the last page url (
    https://dev.freeagent.com/docs/introduction).
  3. Make a further GET request to
    https://api.freeagent.com/v2/invoices?page=X&per_page=Y replacing X
    and Y with the right values.
  4. The last created invoice should be the last invoice in the return
    JSON array.

Regards,
Murray Summers

On Thursday, June 5, 2014 6:57:25 AM UTC+1, vipul Kumar wrote:

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather that
is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?

On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this
should be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent
open or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice
from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent,
and due to which my Invoice reference according to my database is already
exist there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about
that…

Now its a live project.

Vipul,

Glad the reply was helpful and sorry for not fully answering your question.

Could you clarify whether you want to get the last invoice created or the
last invoice reference? How were you planning on using the invoice
reference? Are you aware that there are different types of invoice
referencing schemes that FreeAgent support
http://www.freeagent.com/support/kb/invoicing/invoice-numbering-schemes so
depending on how you plan to use the last invoice reference depends on the
correct way to get the last invoice reference.

The best way to get the last invoice created is the following:

  1. Make a GET request to https://api.freeagent.com/v2/invoices.
  2. Inspect the pagination headers to find the last page url
    (https://dev.freeagent.com/docs/introduction).
  3. Make a further GET request
    to https://api.freeagent.com/v2/invoices?page=X&per_page=Y replacing X and
    Y with the right values.
  4. The last created invoice should be the last invoice in the return
    JSON array.

Regards,
Murray SummersOn Thursday, June 5, 2014 6:57:25 AM UTC+1, vipul Kumar wrote:

Hi murray,

Thanks for helpful reply, but my question is still the same,
Is there any way to get last generated invoice reference no, weather that
is a paid invoice or open / overdue / draft /cancelled.

any tag or option for this?

On Tuesday, 3 June 2014 16:09:46 UTC+5:30, Murray Summers wrote:

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this should
be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent
open or overdue invoices.

Regards,
Murray Summers

On Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice
from freeAgent,
actually my client is habitual of doing direct entries in FreeAgent, and
due to which my Invoice reference according to my database is already exist
there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about that…

Now its a live project.

Vipul,

Thanks for getting in touch.

The reason you are receiving a 406 is your request is malformed. The
request you are making is:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Notice the extra question mark at the end of the URI. Instead this should
be:

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?
https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue

https://api.freeagent.com/v2/invoices?view=recent_open_or_overdue?

Removing that extra question mark should allow you to retrieve recent open
or overdue invoices.

Regards,
Murray SummersOn Tuesday, 3 June 2014 06:04:50 UTC+1, vipul Kumar wrote:

Hi jonathan and all,

I need a urgent help,

Can anyone please assist me, that how can i find last created Invoice from
freeAgent,
actually my client is habitual of doing direct entries in FreeAgent, and
due to which my Invoice reference according to my database is already exist
there,
I am trying to fetch last / recent invoice by using
“recent_open_or_overdue” to view last invoice but its returning “406”
error
,

Please give me a solution, I also try Timeline but not sure about that…

Now its a live project.