Error occured in Invoice add: Base Invoice date is invalid - status code is 422

Hi Ashraf,

As you mention in your email the date format needs to be YYYY-MM-DD which
means the month and day parts of the date need to have leading zeros. If
you format your dates as 2011-09-11 and 2012-08-26 they will work. This
format is known as ISO 8601.

For example:

curl https://api.freeagent.com/v2/invoices -H “Authorization: Bearer
token1” -H “Accept: application/xml” -H “Content-Type: application/json”
-X POST -d "{
"invoice": {
"reference": "166",
"contact": "https: //api.freeagent.com/v2/contacts/1037144",
"status": "Draft",
"discount_percent": 0,
"dated_on": "2011-09-11",
"due_on": "2012-08-26",
"exchange_rate": 0,
"payment_terms_in_days": 30,
"currency": "USD",
"ec_status": "",
"omit_header": false,
"comments": "AddedbyAPIthroughConnect2Field",
"invoice_items": [

    ],
    \"updated_at\": \"\",
    \"created_at\": \"\",
    \"url\": \"\"
}

}"

Kind regards,

GraemeOn 26 July 2012 11:10, Ashraf ashrafwebreaktor@gmail.com wrote:

Dear Forum member,
I have developed an application where i have posting invoice data from one
website to freeagent through API.
For some record i got “*Base Invoice date is invalid *” though the date
format is okay YYYY-MM-DD

Here is the JSON format,
{"invoice":
{"reference":"166",
"contact":"https://api.freeagent.com/v2/contacts/1037144\",
"status":"Draft","discount_percent":0,
"dated_on":"2011-9-11",
"due_on":"2012-8-26",
"exchange_rate":0,
"payment_terms_in_days":30,
"currency":"USD",
"ec_status":"",
"omit_header":false,
"comments":"Added by API through Connect2Field",
"invoice_items":,"updated_at":"","created_at":"","url":""}}

Can any one tell me what is going wring?


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

Graeme Boyd
Senior Software Engineer

Web. freeagent.com http://www.freeagent.com/ Blog. The FreeAgent Blog - FreeAgent
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
FreeAgent | Edinburgh

40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774

Thank you, It resolved my problem.On Thu, Jul 26, 2012 at 4:37 PM, Graeme Boyd graeme.boyd@freeagent.comwrote:

Hi Ashraf,

As you mention in your email the date format needs to be YYYY-MM-DD which
means the month and day parts of the date need to have leading zeros. If
you format your dates as 2011-09-11 and 2012-08-26 they will work. This
format is known as ISO 8601.

For example:

curl https://api.freeagent.com/v2/invoices -H “Authorization: Bearer
token1” -H “Accept: application/xml” -H “Content-Type: application/json”
-X POST -d "{
"invoice": {
"reference": "166",
"contact": "https: //api.freeagent.com/v2/contacts/1037144<http://api.freeagent.com/v2/contacts/1037144\>
",
"status": "Draft",
"discount_percent": 0,
"dated_on": "2011-09-11",
"due_on": "2012-08-26",
"exchange_rate": 0,
"payment_terms_in_days": 30,
"currency": "USD",
"ec_status": "",
"omit_header": false,
"comments": "AddedbyAPIthroughConnect2Field",
"invoice_items": [

    ],
    \"updated_at\": \"\",
    \"created_at\": \"\",
    \"url\": \"\"
}

}"

Kind regards,

Graeme

On 26 July 2012 11:10, Ashraf ashrafwebreaktor@gmail.com wrote:

Dear Forum member,
I have developed an application where i have posting invoice data from
one website to freeagent through API.
For some record i got “*Base Invoice date is invalid *” though the date
format is okay YYYY-MM-DD

Here is the JSON format,
{"invoice":
{"reference":"166",
"contact":"https://api.freeagent.com/v2/contacts/1037144\",
"status":"Draft","discount_percent":0,
"dated_on":"2011-9-11",
"due_on":"2012-8-26",
"exchange_rate":0,
"payment_terms_in_days":30,
"currency":"USD",
"ec_status":"",
"omit_header":false,
"comments":"Added by API through Connect2Field",

"invoice_items":,"updated_at":"","created_at":"","url":""}}

Can any one tell me what is going wring?


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


Graeme Boyd
Senior Software Engineer

Web. freeagent.com http://www.freeagent.com/ Blog. The FreeAgent Blog - FreeAgent
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
FreeAgent | Edinburgh

40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
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.

Kind Regards –
Ashraf Ahmed
eWebCenta
Founder
Business: +8801712824016
Personal: +8801552344937