# Unable to add invoice\_items to existing invoice

**URL:** <https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284>\
**Category:** Uncategorized\
**Created:** [31 July 2013 12:24 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284 "2013-07-31T12:24:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Gimbel](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Jeremy\_Gimbel](https://api-discuss.freeagent.com/u/Jeremy_Gimbel)\
**Post date:** [31 July 2013 12:24 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/1 "2013-07-31T12:24:31Z")

</div>

I’ve been trying to add a line item to an invoice that already exists as a  
draft.

From the docs, I’m sending a PUT to  
[https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)

I’ve constructed an item array:

$line = array(  
‘position’ =\> ‘1000’,  
‘quantity’ =\> ‘1’,  
‘item\_type’ =\> ‘Expenses’,  
‘price’ =\> ‘14.97’,  
‘description’ =\> ‘Credit card convenience fee’

);

Then an items array, and add the item to it.  
$items = array();  
$items[] = $line;

Then the parameter array has the invoice items added:

array(‘invoice\_items’ =\> $items);

This gets PUT to the endpoint, and I get a 200 response back, but the item  
is not added.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Ioan\_Serban](https://api-discuss.freeagent.com/user_avatar/api-discuss.freeagent.com/ioan_serban/32/148_2.png) [@Ioan\_Serban](https://api-discuss.freeagent.com/u/Ioan_Serban)\
**Post date:** [31 July 2013 14:37 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/2 "2013-07-31T14:37:33Z")

</div>

This isn’t possible at the moment, so you will have to keep track of the  
deletions at least. Then you can just send DELETE requests to  
/v2/invoice\_items/xxx for each line item you wish to delete.

Cheers,  
IoanOn Wednesday, 31 July 2013 14:36:56 UTC+1, Nic Wise wrote:

> While you are there Ioan, is there a nice way to say “here’s an  
> invoice (which already exists). Make the invoice lines look like  
> this…”
> 
> If I have an invoice with 3 lines, and update it (download the  
> invoice, make changes, upload it (PUT?)) to only have 2 (eg, remove 2,  
> add one), then I have 4 lines (the original 3, plus the new one)
> 
> I “solved it” by deleting the old invoice and creating a new one,  
> which feels wrong. Tracking each line isn’t really practical.
> 
> On 31 July 2013 14:11, Ioan Serban \<[io...@freeagent.com](mailto:io...@freeagent.com) \<javascript:\>\> wrote:
> 
> > Hi Jeremy,
> > 
> > Sorry for the unclear documentation. The ‘invoice\_items’ array needs to  
> > be a  
> > property on an ‘invoice’ object, so you need something like:
> > 
> > $line = array(  
> > ‘position’ =\> ‘1000’,  
> > ‘quantity’ =\> ‘1’,  
> > ‘item\_type’ =\> ‘Expenses’,  
> > ‘price’ =\> ‘14.97’,  
> > ‘description’ =\> ‘Credit card convenience fee’
> > 
> > );  
> > $items = array();  
> > $items = $line;  
> > $invoice = array(‘invoice’);  
> > $invoice[‘invoice\_items’] = $invoice;
> > 
> > Regards,  
> > Ioan
> > 
> > On Wednesday, 31 July 2013 13:24:31 UTC+1, Jeremy Gimbel wrote:
> > 
> > > I’ve been trying to add a line item to an invoice that already exists  
> > > as a  
> > > draft.
> > > 
> > > From the docs, I’m sending a PUT to  
> > > [https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)
> > > 
> > > I’ve constructed an item array:
> > > 
> > > $line = array(  
> > > ‘position’ =\> ‘1000’,  
> > > ‘quantity’ =\> ‘1’,  
> > > ‘item\_type’ =\> ‘Expenses’,  
> > > ‘price’ =\> ‘14.97’,  
> > > ‘description’ =\> ‘Credit card convenience fee’
> > > 
> > > );
> > > 
> > > Then an items array, and add the item to it.  
> > > $items = array();  
> > > $items = $line;
> > > 
> > > Then the parameter array has the invoice items added:
> > > 
> > > array(‘invoice\_items’ =\> $items);
> > > 
> > > This gets PUT to the endpoint, and I get a 200 response back, but the  
> > > item  
> > > is not added.
> > > 
> > > Any ideas?
> > 
> > –  
> > 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\_ap...@googlegroups.com](mailto:freeagent_ap...@googlegroups.com) \<javascript:\>.  
> > To post to this group, send email to [freeag...@googlegroups.com](mailto:freeag...@googlegroups.com)\<javascript:\>.
> 
> > Visit this group at [http://groups.google.com/group/freeagent\_api](http://groups.google.com/group/freeagent_api).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> –  
> Nic Wise  
> t. +44 7788 592 806 | @fastchicken  
> b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)

---

<div class="post-metadata">

**Author:** ![Jeremy\_Gimbel](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Jeremy\_Gimbel](https://api-discuss.freeagent.com/u/Jeremy_Gimbel)\
**Post date:** [31 July 2013 15:12 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/3 "2013-07-31T15:12:20Z")

</div>

Thanks. I actually saw that and tried it, which returned a 500. Is there  
anything else that needs to be included in the invoice array, or in the  
line items that I’m missing?On Wednesday, July 31, 2013 9:11:41 AM UTC-4, Ioan Serban wrote:

> Hi Jeremy,
> 
> Sorry for the unclear documentation. The ‘invoice\_items’ array needs to be  
> a property on an ‘invoice’ object, so you need something like:
> 
> $line = array(  
> ‘position’ =\> ‘1000’,  
> ‘quantity’ =\> ‘1’,  
> ‘item\_type’ =\> ‘Expenses’,  
> ‘price’ =\> ‘14.97’,  
> ‘description’ =\> ‘Credit card convenience fee’
> 
> );  
> $items = array();  
> $items = $line;  
> $invoice = array(‘invoice’);  
> $invoice[‘invoice\_items’] = $invoice;
> 
> Regards,  
> Ioan
> 
> On Wednesday, 31 July 2013 13:24:31 UTC+1, Jeremy Gimbel wrote:
> 
> > I’ve been trying to add a line item to an invoice that already exists as  
> > a draft.
> > 
> > From the docs, I’m sending a PUT to  
> > [https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)
> > 
> > I’ve constructed an item array:
> > 
> > $line = array(  
> > ‘position’ =\> ‘1000’,  
> > ‘quantity’ =\> ‘1’,  
> > ‘item\_type’ =\> ‘Expenses’,  
> > ‘price’ =\> ‘14.97’,  
> > ‘description’ =\> ‘Credit card convenience fee’
> > 
> > );
> > 
> > Then an items array, and add the item to it.  
> > $items = array();  
> > $items = $line;
> > 
> > Then the parameter array has the invoice items added:
> > 
> > array(‘invoice\_items’ =\> $items);
> > 
> > This gets PUT to the endpoint, and I get a 200 response back, but the  
> > item is not added.
> > 
> > Any ideas?

---

<div class="post-metadata">

**Author:** ![Nic\_Wise](https://api-discuss.freeagent.com/user_avatar/api-discuss.freeagent.com/nic_wise/32/58_2.png) [@Nic\_Wise](https://api-discuss.freeagent.com/u/Nic_Wise)\
**Post date:** [31 July 2013 15:27 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/4 "2013-07-31T15:27:54Z")

</div>

Thanks. I have it working now so that it deletes all the old lines and  
posts the invoice as an update (with lines)

mobileAgent 2.1.1 I think 🙂

BTW, the docs for the invoice page is all over the place. refers to  
estimates in one URL, the “id” property for each invoice\_line is  
actually “url”, tho you can’t ever SEND one (appears to have to be  
without url when posting the parent invoice)…On 31 July 2013 15:37, Ioan Serban [ioan@freeagent.com](mailto:ioan@freeagent.com) wrote:

> This isn’t possible at the moment, so you will have to keep track of the  
> deletions at least. Then you can just send DELETE requests to  
> /v2/invoice\_items/xxx for each line item you wish to delete.
> 
> Cheers,  
> Ioan
> 
> On Wednesday, 31 July 2013 14:36:56 UTC+1, Nic Wise wrote:
> 
> > While you are there Ioan, is there a nice way to say “here’s an  
> > invoice (which already exists). Make the invoice lines look like  
> > this…”
> > 
> > If I have an invoice with 3 lines, and update it (download the  
> > invoice, make changes, upload it (PUT?)) to only have 2 (eg, remove 2,  
> > add one), then I have 4 lines (the original 3, plus the new one)
> > 
> > I “solved it” by deleting the old invoice and creating a new one,  
> > which feels wrong. Tracking each line isn’t really practical.
> > 
> > On 31 July 2013 14:11, Ioan Serban [io...@freeagent.com](mailto:io...@freeagent.com) wrote:
> > 
> > > Hi Jeremy,
> > > 
> > > Sorry for the unclear documentation. The ‘invoice\_items’ array needs to  
> > > be a  
> > > property on an ‘invoice’ object, so you need something like:
> > > 
> > > $line = array(  
> > > ‘position’ =\> ‘1000’,  
> > > ‘quantity’ =\> ‘1’,  
> > > ‘item\_type’ =\> ‘Expenses’,  
> > > ‘price’ =\> ‘14.97’,  
> > > ‘description’ =\> ‘Credit card convenience fee’
> > > 
> > > );  
> > > $items = array();  
> > > $items = $line;  
> > > $invoice = array(‘invoice’);  
> > > $invoice[‘invoice\_items’] = $invoice;
> > > 
> > > Regards,  
> > > Ioan
> > > 
> > > On Wednesday, 31 July 2013 13:24:31 UTC+1, Jeremy Gimbel wrote:
> > > 
> > > > I’ve been trying to add a line item to an invoice that already exists  
> > > > as a  
> > > > draft.
> > > > 
> > > > From the docs, I’m sending a PUT to  
> > > > [https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)
> > > > 
> > > > I’ve constructed an item array:
> > > > 
> > > > $line = array(  
> > > > ‘position’ =\> ‘1000’,  
> > > > ‘quantity’ =\> ‘1’,  
> > > > ‘item\_type’ =\> ‘Expenses’,  
> > > > ‘price’ =\> ‘14.97’,  
> > > > ‘description’ =\> ‘Credit card convenience fee’
> > > > 
> > > > );
> > > > 
> > > > Then an items array, and add the item to it.  
> > > > $items = array();  
> > > > $items = $line;
> > > > 
> > > > Then the parameter array has the invoice items added:
> > > > 
> > > > array(‘invoice\_items’ =\> $items);
> > > > 
> > > > This gets PUT to the endpoint, and I get a 200 response back, but the  
> > > > item  
> > > > is not added.
> > > > 
> > > > Any ideas?
> > > 
> > > –  
> > > 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\_ap...@googlegroups.com](mailto:freeagent_ap...@googlegroups.com).  
> > > To post to this group, send email to [freeag...@googlegroups.com](mailto:freeag...@googlegroups.com).  
> > > Visit this group at [http://groups.google.com/group/freeagent\_api](http://groups.google.com/group/freeagent_api).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > –  
> > Nic Wise  
> > t. +44 7788 592 806 | @fastchicken  
> > b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)
> 
> –  
> 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](http://groups.google.com/group/freeagent_api).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

Nic Wise  
t. +44 7788 592 806 | @fastchicken  
b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)

---

<div class="post-metadata">

**Author:** ![Ioan\_Serban](https://api-discuss.freeagent.com/user_avatar/api-discuss.freeagent.com/ioan_serban/32/148_2.png) [@Ioan\_Serban](https://api-discuss.freeagent.com/u/Ioan_Serban)\
**Post date:** [31 July 2013 15:34 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/5 "2013-07-31T15:34:56Z")

</div>

Jeremy:

I think my example was wrong. Doing:

$invoice = array();  
$invoice[‘invoice’][‘invoice\_items’] = $items;

should however work. Basically your JSON needs to be in the format:

{“invoice”: {“invoice\_items”: [{…item1…}, {…item2…}]}}

Nic: I’m going to have a thorough look at the documentation in the  
following weeks and bring it up to date with the current behaviour of the  
API, so it’s going to be clearer soon and save some sweat 🙂

Cheers,  
IoanOn Wednesday, 31 July 2013 16:27:54 UTC+1, Nic Wise wrote:

> Thanks. I have it working now so that it deletes all the old lines and  
> posts the invoice as an update (with lines)
> 
> mobileAgent 2.1.1 I think 🙂
> 
> BTW, the docs for the invoice page is all over the place. refers to  
> estimates in one URL, the “id” property for each invoice\_line is  
> actually “url”, tho you can’t ever SEND one (appears to have to be  
> without url when posting the parent invoice)…
> 
> On 31 July 2013 15:37, Ioan Serban \<[io...@freeagent.com](mailto:io...@freeagent.com) \<javascript:\>\> wrote:
> 
> > This isn’t possible at the moment, so you will have to keep track of the  
> > deletions at least. Then you can just send DELETE requests to  
> > /v2/invoice\_items/xxx for each line item you wish to delete.
> > 
> > Cheers,  
> > Ioan
> > 
> > On Wednesday, 31 July 2013 14:36:56 UTC+1, Nic Wise wrote:
> > 
> > > While you are there Ioan, is there a nice way to say “here’s an  
> > > invoice (which already exists). Make the invoice lines look like  
> > > this…”
> > > 
> > > If I have an invoice with 3 lines, and update it (download the  
> > > invoice, make changes, upload it (PUT?)) to only have 2 (eg, remove 2,  
> > > add one), then I have 4 lines (the original 3, plus the new one)
> > > 
> > > I “solved it” by deleting the old invoice and creating a new one,  
> > > which feels wrong. Tracking each line isn’t really practical.
> > > 
> > > On 31 July 2013 14:11, Ioan Serban [io...@freeagent.com](mailto:io...@freeagent.com) wrote:
> > > 
> > > > Hi Jeremy,
> > > > 
> > > > Sorry for the unclear documentation. The ‘invoice\_items’ array needs  
> > > > to  
> > > > be a  
> > > > property on an ‘invoice’ object, so you need something like:
> > > > 
> > > > $line = array(  
> > > > ‘position’ =\> ‘1000’,  
> > > > ‘quantity’ =\> ‘1’,  
> > > > ‘item\_type’ =\> ‘Expenses’,  
> > > > ‘price’ =\> ‘14.97’,  
> > > > ‘description’ =\> ‘Credit card convenience fee’
> > > > 
> > > > );  
> > > > $items = array();  
> > > > $items = $line;  
> > > > $invoice = array(‘invoice’);  
> > > > $invoice[‘invoice\_items’] = $invoice;
> > > > 
> > > > Regards,  
> > > > Ioan
> > > > 
> > > > On Wednesday, 31 July 2013 13:24:31 UTC+1, Jeremy Gimbel wrote:
> > > > 
> > > > > I’ve been trying to add a line item to an invoice that already  
> > > > > exists  
> > > > > as a  
> > > > > draft.
> > > > > 
> > > > > From the docs, I’m sending a PUT to  
> > > > > [https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)
> > > > > 
> > > > > I’ve constructed an item array:
> > > > > 
> > > > > $line = array(  
> > > > > ‘position’ =\> ‘1000’,  
> > > > > ‘quantity’ =\> ‘1’,  
> > > > > ‘item\_type’ =\> ‘Expenses’,  
> > > > > ‘price’ =\> ‘14.97’,  
> > > > > ‘description’ =\> ‘Credit card convenience fee’
> > > > > 
> > > > > );
> > > > > 
> > > > > Then an items array, and add the item to it.  
> > > > > $items = array();  
> > > > > $items = $line;
> > > > > 
> > > > > Then the parameter array has the invoice items added:
> > > > > 
> > > > > array(‘invoice\_items’ =\> $items);
> > > > > 
> > > > > This gets PUT to the endpoint, and I get a 200 response back, but  
> > > > > the  
> > > > > item  
> > > > > is not added.
> > > > > 
> > > > > Any ideas?
> > > > 
> > > > –  
> > > > 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\_ap...@googlegroups.com](mailto:freeagent_ap...@googlegroups.com).  
> > > > To post to this group, send email to [freeag...@googlegroups.com](mailto:freeag...@googlegroups.com).  
> > > > Visit this group at [http://groups.google.com/group/freeagent\_api](http://groups.google.com/group/freeagent_api).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > 
> > > –  
> > > Nic Wise  
> > > t. +44 7788 592 806 | @fastchicken  
> > > b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)
> > 
> > –  
> > 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\_ap...@googlegroups.com](mailto:freeagent_ap...@googlegroups.com) \<javascript:\>.  
> > To post to this group, send email to [freeag...@googlegroups.com](mailto:freeag...@googlegroups.com)\<javascript:\>.
> 
> > Visit this group at [http://groups.google.com/group/freeagent\_api](http://groups.google.com/group/freeagent_api).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> –  
> Nic Wise  
> t. +44 7788 592 806 | @fastchicken  
> b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)

---

<div class="post-metadata">

**Author:** ![Ioan\_Serban](https://api-discuss.freeagent.com/user_avatar/api-discuss.freeagent.com/ioan_serban/32/148_2.png) [@Ioan\_Serban](https://api-discuss.freeagent.com/u/Ioan_Serban)\
**Post date:** [31 July 2013 13:11 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/6 "2013-07-31T13:11:41Z")

</div>

Hi Jeremy,

Sorry for the unclear documentation. The ‘invoice\_items’ array needs to be  
a property on an ‘invoice’ object, so you need something like:

$line = array(  
‘position’ =\> ‘1000’,  
‘quantity’ =\> ‘1’,  
‘item\_type’ =\> ‘Expenses’,  
‘price’ =\> ‘14.97’,  
‘description’ =\> ‘Credit card convenience fee’

);  
$items = array();  
$items = $line;  
$invoice = array(‘invoice’);  
$invoice[‘invoice\_items’] = $invoice;

Regards,  
IoanOn Wednesday, 31 July 2013 13:24:31 UTC+1, Jeremy Gimbel wrote:

> I’ve been trying to add a line item to an invoice that already exists as a  
> draft.
> 
> From the docs, I’m sending a PUT to  
> [https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)
> 
> I’ve constructed an item array:
> 
> $line = array(  
> ‘position’ =\> ‘1000’,  
> ‘quantity’ =\> ‘1’,  
> ‘item\_type’ =\> ‘Expenses’,  
> ‘price’ =\> ‘14.97’,  
> ‘description’ =\> ‘Credit card convenience fee’
> 
> );
> 
> Then an items array, and add the item to it.  
> $items = array();  
> $items = $line;
> 
> Then the parameter array has the invoice items added:
> 
> array(‘invoice\_items’ =\> $items);
> 
> This gets PUT to the endpoint, and I get a 200 response back, but the item  
> is not added.
> 
> Any ideas?

---

<div class="post-metadata">

**Author:** ![Nic\_Wise](https://api-discuss.freeagent.com/user_avatar/api-discuss.freeagent.com/nic_wise/32/58_2.png) [@Nic\_Wise](https://api-discuss.freeagent.com/u/Nic_Wise)\
**Post date:** [31 July 2013 13:36 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/7 "2013-07-31T13:36:56Z")

</div>

While you are there Ioan, is there a nice way to say “here’s an  
invoice (which already exists). Make the invoice lines look like  
this…”

If I have an invoice with 3 lines, and update it (download the  
invoice, make changes, upload it (PUT?)) to only have 2 (eg, remove 2,  
add one), then I have 4 lines (the original 3, plus the new one)

I “solved it” by deleting the old invoice and creating a new one,  
which feels wrong. Tracking each line isn’t really practical.On 31 July 2013 14:11, Ioan Serban [ioan@freeagent.com](mailto:ioan@freeagent.com) wrote:

> Hi Jeremy,
> 
> Sorry for the unclear documentation. The ‘invoice\_items’ array needs to be a  
> property on an ‘invoice’ object, so you need something like:
> 
> $line = array(  
> ‘position’ =\> ‘1000’,  
> ‘quantity’ =\> ‘1’,  
> ‘item\_type’ =\> ‘Expenses’,  
> ‘price’ =\> ‘14.97’,  
> ‘description’ =\> ‘Credit card convenience fee’
> 
> );  
> $items = array();  
> $items = $line;  
> $invoice = array(‘invoice’);  
> $invoice[‘invoice\_items’] = $invoice;
> 
> Regards,  
> Ioan
> 
> On Wednesday, 31 July 2013 13:24:31 UTC+1, Jeremy Gimbel wrote:
> 
> > I’ve been trying to add a line item to an invoice that already exists as a  
> > draft.
> > 
> > From the docs, I’m sending a PUT to  
> > [https://api.sandbox.freeagent.com/v2/invoices/xxx](https://api.sandbox.freeagent.com/v2/invoices/xxx)
> > 
> > I’ve constructed an item array:
> > 
> > $line = array(  
> > ‘position’ =\> ‘1000’,  
> > ‘quantity’ =\> ‘1’,  
> > ‘item\_type’ =\> ‘Expenses’,  
> > ‘price’ =\> ‘14.97’,  
> > ‘description’ =\> ‘Credit card convenience fee’
> > 
> > );
> > 
> > Then an items array, and add the item to it.  
> > $items = array();  
> > $items = $line;
> > 
> > Then the parameter array has the invoice items added:
> > 
> > array(‘invoice\_items’ =\> $items);
> > 
> > This gets PUT to the endpoint, and I get a 200 response back, but the item  
> > is not added.
> > 
> > Any ideas?
> 
> –  
> 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](http://groups.google.com/group/freeagent_api).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

Nic Wise  
t. +44 7788 592 806 | @fastchicken  
b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)

---

<div class="post-metadata">

**Author:** ![Jeremy\_Gimbel](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@Jeremy\_Gimbel](https://api-discuss.freeagent.com/u/Jeremy_Gimbel)\
**Post date:** [31 July 2013 15:56 UTC](https://api-discuss.freeagent.com/t/unable-to-add-invoice-items-to-existing-invoice/284/8 "2013-07-31T15:56:44Z")

</div>

Ah never mind me. I was using an OAUTH client which wasn’t sending the data  
as a JSON string.

Thanks for the help!
