Create invoice, dated_on format?

Looks like this has been asked before but either the documentation is wrong or I’m doing something wrong… My payload is as follows:

{'dated_on': '2016-12-21', 'status': 'Sent', 'contact': '', 'client_contact_name': 'James Smith', 'reference': 'CW1015', 'payment_terms_in_days': 30, 'invoice_items': [{'price': 350.0, 'description': 'Invoice generated from API', 'quantity': 1}], 'payment_terms': 'Net 30 days'}

My error is as follows:

{"errors":[{"message":"payment_terms_in_days is not a number"},{"message":"Invoice Date is not valid"}]}

As you can see my payment_terms_in_days is most definitely a number and my date is definitely the format that is listed in the documentation. For completeness I tried turning the payment_terms_in_days into a string, that didn’t work; I also tried the proper/full ISO date, as referenced in another script, and that also didn’t work.

Your documentation is really thin on examples; as a result I’m finding it really difficult to prove that either it’s my code, or the documentation, or something else that is broken. Especially for something simple like this that shouldn’t really pose a problem. Also the error message is misleading as there is no field called Invoice Date (I assume it refers to dated_on but again, who am I to assume?).

If you can help me resolve the above I’d greatly appreciate it.

Many thanks


edit: missed a quotation mark in my code (confirmed that this is not what’s causing the problem)

I’ve fixed this.

Correct code was actually just to enclose my own code in an {invoice:{...}} object. Error message was misleading (should really be a “invoice object is missing”).

Glad you got it sorted, Daniel.