# Invoice Creation Problem

**URL:** <https://api-discuss.freeagent.com/t/invoice-creation-problem/198>\
**Category:** Uncategorized\
**Created:** [16 July 2013 08:13 UTC](https://api-discuss.freeagent.com/t/invoice-creation-problem/198 "2013-07-16T08:13:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cheesa](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@Cheesa](https://api-discuss.freeagent.com/u/Cheesa)\
**Post date:** [16 July 2013 08:13 UTC](https://api-discuss.freeagent.com/t/invoice-creation-problem/198/1 "2013-07-16T08:13:25Z")

</div>

Hi Developers,

I am creating invoice using code get from  
[https://github.com/nicwise/FreeAgent](https://github.com/nicwise/FreeAgent). My code is like:

```
        Invoice c = new Invoice();
        c.comments = "Comments";
        c.contact = "Contact";
        c.created_at = "sometime";
        c.currency = "any";
        c.dated_on = "somedate";
        c.discount_percent = 6.6;
        c.due_on = "nothing";
        c.ec_status = "ec status";
        c.exchange_rate = 9.9;
        c.invoice_items = new List<InvoiceItem>();
        c.net_value = 4.4;
        c.payment_terms_in_days = 10;
        c.project = "poject";
        c.reference = "referece";
        c.sales_tax_value = 4.4;
        c.status = "status";
        c.updated_at = "sometime";
        c.written_off_date = "somedate";

        InvoiceClient ic = new InvoiceClient(_client);
        ic.Put(c);

```

When i try to create invoice using Put method it gives me error response  
({“errors”:[{“message”:“Contact not found for this  
company”},{“message”:“Project not found for this company”}]})

Kindly tell me where i am wrong? Either i am going wrong way to create  
invoice or some other problem?

Kind Regards,  
Cheesa,  
Developer, Ambosco, Sherserve

---

<div class="post-metadata">

**Author:** ![Cheesa](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@Cheesa](https://api-discuss.freeagent.com/u/Cheesa)\
**Post date:** [16 July 2013 10:50 UTC](https://api-discuss.freeagent.com/t/invoice-creation-problem/198/2 "2013-07-16T10:50:22Z")

</div>

Thanks Nic Wise. it really help me. 🙂

Kind Regards,  
Cheesa, Ambosco, SherserveOn Tuesday, July 16, 2013 2:05:14 PM UTC+5, Nic Wise wrote:

> On 16 July 2013 09:13, Cheesa \<[fake...@gmail.com](mailto:fake...@gmail.com) \<javascript:\>\> wrote:
> 
> > Hi Developers,
> > 
> > I am creating invoice using code get from  
> > [GitHub - nicwise/FreeAgent: A basic .NET client for FreeAgent.com (work in progress)](https://github.com/nicwise/FreeAgent). My code is like:
> 
> PLEASE read the docs. I know RTFM is a cop-out, but still
> 
> [FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/invoices)
> 
> > ```
> > Invoice c = new Invoice(); 
> > c.comments = "Comments"; 
> > c.contact = "Contact"; 
> > 
> > ```
> 
> this is a reference to a contact, eg  
> [http://api.freeagent.com/v2/contacts/12345](http://api.freeagent.com/v2/contacts/12345)
> 
> (you can also use /v2/contacts/12345)
> 
> > ```
> > c.created_at = "sometime"; 
> > 
> > ```
> 
> 2013-07-11
> 
> > ```
> > c.currency = "any"; 
> > 
> > ```
> 
> GBP
> 
> > ```
> > c.dated_on = "somedate"; 
> > 
> > ```
> 
> 2013-07-11
> 
> > ```
> > c.discount_percent = 6.6; 
> > c.due_on = "nothing"; 
> > 
> > ```
> 
> its a required field.
> 
> > ```
> > c.ec_status = "ec status"; 
> > c.exchange_rate = 9.9; 
> > c.invoice_items = new List<InvoiceItem>(); 
> > c.net_value = 4.4; 
> > c.payment_terms_in_days = 10; 
> > c.project = "poject"; 
> > 
> > ```
> 
> see the contact one above
> 
> > ```
> > c.reference = "referece"; 
> > c.sales_tax_value = 4.4; 
> > c.status = "status"; 
> > c.updated_at = "sometime"; 
> > c.written_off_date = "somedate"; 
> > 
> > InvoiceClient ic = new InvoiceClient(_client); 
> > ic.Put(c); 
> > 
> > ```
> > 
> > When i try to create invoice using Put method it gives me error response  
> > ({“errors”:[{“message”:“Contact not found for this  
> > company”},{“message”:“Project not found for this company”}]})
> > 
> > Kindly tell me where i am wrong? Either i am going wrong way to create  
> > invoice or some other problem?
> 
> [FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/invoices#create-an-invoice)
> 
> also
> 
> Invoices, in the current version of my client, are not fully  
> implemented, so you may/will have to make changes to get it working.  
> I’m working on that at the moment for another project, but I doubt  
> submitting an invoice works _at the moment_. It only has enough in it  
> for the work I’ve done so far (it’s not an official client)
> 
> Pulling invoices down does work tho. If you GET an existing invoice,  
> and have a look at the object which is returned, it gives you a very  
> good idea of what the values should be.
> 
> –  
> Nic Wise  
> t. +44 7788 592 806 | @fastchicken  
> b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)

---

<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:** [16 July 2013 09:05 UTC](https://api-discuss.freeagent.com/t/invoice-creation-problem/198/3 "2013-07-16T09:05:14Z")

</div>

> Hi Developers,
> 
> I am creating invoice using code get from  
> [GitHub - nicwise/FreeAgent: A basic .NET client for FreeAgent.com (work in progress)](https://github.com/nicwise/FreeAgent). My code is like:

PLEASE read the docs. I know RTFM is a cop-out, but still

> **[FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/invoices)**
>
> FreeAgent API resources, documentation and discussions

> ```
> Invoice c = new Invoice();
> c.comments = "Comments";
> c.contact = "Contact";
> 
> ```

this is a reference to a contact, eg [http://api.freeagent.com/v2/contacts/12345](http://api.freeagent.com/v2/contacts/12345)

(you can also use /v2/contacts/12345)

> ```
> c.created_at = "sometime";
> 
> ```

2013-07-11

> ```
> c.currency = "any";
> 
> ```

GBP

> ```
> c.dated_on = "somedate";
> 
> ```

2013-07-11

> ```
> c.discount_percent = 6.6;
> c.due_on = "nothing";
> 
> ```

its a required field.

> ```
> c.ec_status = "ec status";
> c.exchange_rate = 9.9;
> c.invoice_items = new List<InvoiceItem>();
> c.net_value = 4.4;
> c.payment_terms_in_days = 10;
> c.project = "poject";
> 
> ```

see the contact one above

> ```
> c.reference = "referece";
> c.sales_tax_value = 4.4;
> c.status = "status";
> c.updated_at = "sometime";
> c.written_off_date = "somedate";
> 
> InvoiceClient ic = new InvoiceClient(_client);
> ic.Put(c);
> 
> ```
> 
> When i try to create invoice using Put method it gives me error response  
> ({“errors”:[{“message”:“Contact not found for this  
> company”},{“message”:“Project not found for this company”}]})
> 
> Kindly tell me where i am wrong? Either i am going wrong way to create  
> invoice or some other problem?

> **[FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/invoices#create-an-invoice)**
>
> FreeAgent API resources, documentation and discussions

also

Invoices, in the current version of my client, are not fully  
implemented, so you may/will have to make changes to get it working.  
I’m working on that at the moment for another project, but I doubt  
submitting an invoice works _at the moment_. It only has enough in it  
for the work I’ve done so far (it’s not an official client)

Pulling invoices down does work tho. If you GET an existing invoice,  
and have a look at the object which is returned, it gives you a very  
good idea of what the values should be.

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

---

<div class="post-metadata">

**Author:** ![koktail](https://api-discuss.freeagent.com/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@koktail](https://api-discuss.freeagent.com/u/koktail)\
**Post date:** [24 October 2014 06:42 UTC](https://api-discuss.freeagent.com/t/invoice-creation-problem/198/4 "2014-10-24T06:42:39Z")

</div>

[https://lh6.googleusercontent.com/-IsaUMq-wE3c/VEnkI2Kdt5I/AAAAAAAAAFc/5300oY3OZIw/s1600/freeagent.png](https://lh6.googleusercontent.com/-IsaUMq-wE3c/VEnkI2Kdt5I/AAAAAAAAAFc/5300oY3OZIw/s1600/freeagent.png)

I GET an existing invoice, object showing me contact in these formats “[https://api.sandbox.freeagent.com/v2/contacts/27387](https://api.sandbox.freeagent.com/v2/contacts/27387)” AND " /v2/contacts/27387". Now for creating invoice when i am giving this as contact object it shows Object reference exception. kindly help.On Tuesday, July 16, 2013 2:05:14 PM UTC+5, Nic Wise wrote:

> On 16 July 2013 09:13, Cheesa \<[fake...@gmail.com](mailto:fake...@gmail.com) \<javascript:\>\> wrote:
> 
> > Hi Developers,
> > 
> > I am creating invoice using code get from  
> > [GitHub - nicwise/FreeAgent: A basic .NET client for FreeAgent.com (work in progress)](https://github.com/nicwise/FreeAgent). My code is like:
> 
> PLEASE read the docs. I know RTFM is a cop-out, but still
> 
> [FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/invoices)
> 
> > ```
> > Invoice c = new Invoice(); 
> > c.comments = "Comments"; 
> > c.contact = "Contact"; 
> > 
> > ```
> 
> this is a reference to a contact, eg  
> [http://api.freeagent.com/v2/contacts/12345](http://api.freeagent.com/v2/contacts/12345)  
> [http://www.google.com/url?q=http%3A%2F%2Fapi.freeagent.com%2Fv2%2Fcontacts%2F12345&sa=D&sntz=1&usg=AFQjCNEWOOd6JIBo07g7XqN5QyYNCr\_Kkg](http://www.google.com/url?q=http%3A%2F%2Fapi.freeagent.com%2Fv2%2Fcontacts%2F12345&sa=D&sntz=1&usg=AFQjCNEWOOd6JIBo07g7XqN5QyYNCr_Kkg)
> 
> (you can also use /v2/contacts/12345)
> 
> > ```
> > c.created_at = "sometime"; 
> > 
> > ```
> 
> 2013-07-11
> 
> > ```
> > c.currency = "any"; 
> > 
> > ```
> 
> GBP
> 
> > ```
> > c.dated_on = "somedate"; 
> > 
> > ```
> 
> 2013-07-11
> 
> > ```
> > c.discount_percent = 6.6; 
> > c.due_on = "nothing"; 
> > 
> > ```
> 
> its a required field.
> 
> > ```
> > c.ec_status = "ec status"; 
> > c.exchange_rate = 9.9; 
> > c.invoice_items = new List<InvoiceItem>(); 
> > c.net_value = 4.4; 
> > c.payment_terms_in_days = 10; 
> > c.project = "poject"; 
> > 
> > ```
> 
> see the contact one above
> 
> > ```
> > c.reference = "referece"; 
> > c.sales_tax_value = 4.4; 
> > c.status = "status"; 
> > c.updated_at = "sometime"; 
> > c.written_off_date = "somedate"; 
> > 
> > InvoiceClient ic = new InvoiceClient(_client); 
> > ic.Put(c); 
> > 
> > ```
> > 
> > When i try to create invoice using Put method it gives me error response  
> > ({“errors”:[{“message”:“Contact not found for this  
> > company”},{“message”:“Project not found for this company”}]})
> > 
> > Kindly tell me where i am wrong? Either i am going wrong way to create  
> > invoice or some other problem?
> 
> [FreeAgent Developer Dashboard](https://dev.freeagent.com/docs/invoices#create-an-invoice)
> 
> also
> 
> Invoices, in the current version of my client, are not fully  
> implemented, so you may/will have to make changes to get it working.  
> I’m working on that at the moment for another project, but I doubt  
> submitting an invoice works _at the moment_. It only has enough in it  
> for the work I’ve done so far (it’s not an official client)
> 
> Pulling invoices down does work tho. If you GET an existing invoice,  
> and have a look at the object which is returned, it gives you a very  
> good idea of what the values should be.
> 
> –  
> Nic Wise  
> t. +44 7788 592 806 | @fastchicken  
> b. [http://www.fastchicken.co.nz/](http://www.fastchicken.co.nz/)
