Comment invoice_item is invalid

Hi Nick,

I’ve tried the JSON version of your request on a test account and it is
working correctly. Are you still having problems? If so, can you send the
JSON that your code produces please.

To test your code I used curl and this is the command that works for me (I
changed the project and contact ids to ones on my account):

curl -H “Accept: application/json” -H “Authorization: Bearer 1as…yd” "
https://api.freeagent.com/v2/invoices" -H “Content-Type: application/json”
-X POST -d ‘{
“invoice”: {
“contact”: “https://api.freeagent.com/v2/contacts/1290662”,
“project”: “https://api.freeagent.com/v2/projects/330156”,
“status”: “Draft”,
“dated_on”: “2012-12-02T00:00:00+00:00”,
“payment_terms_in_days”: 14,
“invoice_items”: [
{
“item_type”: “-no unit-”,
“position”: 1,
“quantity”: 10,
“price”: 0.72,
“sales_tax_rate”: 20,
“description”: “Transaction fee, 01/Sep/2012 to 01/Dec/2012
(UTC)”
},
{
“item_type”: “Comment”,
“position”: 2,
“description”: “Project: John Smith and Son eCommerce”
}
]
}
}’

Regards,
Harry MillsOn Wed, Dec 26, 2012 at 5:25 PM, Nick Malyon nick.malyon@gmail.com wrote:

Hi Guys,

Can anyone help with what’s wrong with this data when creating an invoice
please?

{:invoice=>
{:contact=>“https://api.freeagent.com/v2/contacts/139667”,
:project=>“https://api.freeagent.com/v2/projects/228277”,
:status=>“Draft”,
:dated_on=>“2012-12-02T00:00:00+00:00”,
:payment_terms_in_days=>14,
:invoice_items=>
[{:item_type=>"-no unit-",
:position=>1,
:quantity=>10,
:price=>0.72,
:sales_tax_rate=>20,
:description=>“Transaction fee, 01/Sep/2012 to 01/Dec/2012 (UTC)”},
{:item_type=>“Comment”,
:position=>2,
:description=>“Project: John Smith and Son eCommerce”}]}}

The error returned is:

{“errors”:[{“message”:“invoice_items.item_type is not an accepted
value”},{“message”:“invoice_items contain errors”}]}

At first I wondered if it was the undocumented ‘-no unit-’ type, but
changing this to ‘Services’ returns the same error. Submitting just the
first item creates an invoice fine, so I’m certain the error comes from the
second ‘Comment’ item.

Cheers!

  • Nick


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

Hey Harry,

Thanks for checking this. Your post made me look a bit closer at what I
was doing and I’d fallen into the classic trap of sending the data in as
parameters rather than the body of the post.

Pleased to say it very much does work!

Cheers,

  • NickOn Monday, 7 January 2013 11:12:00 UTC, Harry wrote:

Hi Nick,

I’ve tried the JSON version of your request on a test account and it is
working correctly. Are you still having problems? If so, can you send the
JSON that your code produces please.

To test your code I used curl and this is the command that works for me (I
changed the project and contact ids to ones on my account):

curl -H “Accept: application/json” -H “Authorization: Bearer 1as…yd” "
https://api.freeagent.com/v2/invoices" -H “Content-Type:
application/json” -X POST -d ‘{
“invoice”: {
“contact”: “https://api.freeagent.com/v2/contacts/1290662”,
“project”: “https://api.freeagent.com/v2/projects/330156”,
“status”: “Draft”,
“dated_on”: “2012-12-02T00:00:00+00:00”,
“payment_terms_in_days”: 14,
“invoice_items”: [
{
“item_type”: “-no unit-”,
“position”: 1,
“quantity”: 10,
“price”: 0.72,
“sales_tax_rate”: 20,
“description”: “Transaction fee, 01/Sep/2012 to
01/Dec/2012 (UTC)”
},
{
“item_type”: “Comment”,
“position”: 2,
“description”: “Project: John Smith and Son eCommerce”
}
]
}
}’

Regards,
Harry Mills

On Wed, Dec 26, 2012 at 5:25 PM, Nick Malyon <nick....@gmail.com<javascript:> wrote:

Hi Guys,

Can anyone help with what’s wrong with this data when creating an invoice
please?

{:invoice=>
{:contact=>“https://api.freeagent.com/v2/contacts/139667”,
:project=>“https://api.freeagent.com/v2/projects/228277”,
:status=>“Draft”,
:dated_on=>“2012-12-02T00:00:00+00:00”,
:payment_terms_in_days=>14,
:invoice_items=>
[{:item_type=>"-no unit-",
:position=>1,
:quantity=>10,
:price=>0.72,
:sales_tax_rate=>20,
:description=>“Transaction fee, 01/Sep/2012 to 01/Dec/2012 (UTC)”},
{:item_type=>“Comment”,
:position=>2,
:description=>“Project: John Smith and Son eCommerce”}]}}

The error returned is:

{“errors”:[{“message”:“invoice_items.item_type is not an accepted
value”},{“message”:“invoice_items contain errors”}]}

At first I wondered if it was the undocumented ‘-no unit-’ type, but
changing this to ‘Services’ returns the same error. Submitting just the
first item creates an invoice fine, so I’m certain the error comes from the
second ‘Comment’ item.

Cheers!

  • Nick


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/-/NaYbAaiHtbwJ.
To post to this group, send email to freeag...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
freeagent_ap...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/freeagent_api?hl=en.