Error: 422 Client Error: Unprocessable Entity for url

We use a Python script to import (create) invoices. This has worked well for years, but has just started failing with the following error:

Error: 422 Client Error: Unprocessable Entity for url:

Have there been changes on the FreeAgent API?

    faInvoice = {
        "invoice": {
            "contact":"" + faContactId,
            "client_contact_name":invoice["attention"] if "attention" in invoice else None,
            "comments":"%s" % (faInvoiceComment),
            'send_reminder_emails': True,
            "payment_methods": {


    # Post to FA

    print("Posting invoice " + invoice["invoiceNumber"] + " for " + invoice["company"]["name"]+" to FreeAgent...")

        response ="invoices",faInvoice)
        print("*FreeAgent-InvoiceSync* could not post invoice to FreeAgent.\n```%s```" % (faInvoice))

Hi there Oliver,

Just to let you know I’ve raised this for the relevant developer team to investigate further and one of us should be able to get back to you with an answer shortly.

Thank you for your patience!

As a follow up, would it be possible for you to share the full body text of the error returned when you make this request?

If you’re worried about sensitive information in the request, you can send it to me as a direct message here instead.

Hi Wil,

Please see below…

Traceback (most recent call last):
File “C:\ … \FreeAgent\”, line 240, in < module >
response =“invoices”,faInvoice)
File “C:\ … \FreeAgent\”, line 50, in post
File “C:\Python27\lib\site-packages\requests\”, line 893, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 422 Client Error: Unprocessable Entity for url:

Hi Wil,

Any update? Do you need any more information?

Hi Oliver,

Thank you for your patience, from looking at the payload you used, I note that you’ve both go_cardless_preauth and stripe as true. We’ve recently changed how our invoicing works that only one of these can be true for a given invoice - you can read more here about the new additional GoCardless functionality that has caused us to make this change.

However, you should have received an error in the body of the 422 response that informs you this is the reason for the request failing, I’ll going to flag that to the relevant team to investigate further.



Hi Wil,

Thanks for that - spot on. I have changed: “stripe”:True to “stripe”:False and the script now works again.

Kind regards,


1 Like