Problem with API based Invoice creation - ""The email field is required ...."

Hey there,

we are testing the API of the hosted version of Invoiceninja, we love the tool and want to automate the invoicing for our users.

We are testing the API with curl and having troubles with adding a invoice including invoice items via API.

Following request works:
curl -X POST https://app.invoiceninja.com/api/v1/invoices -H "Content-Type:application/json" -d '{"client_id":"14"}' -H "X-Ninja-Token:OURTOKEN" -H "X-Requested-With: XMLHttpRequest"

Following request just results in a error:

curl -X POST https://app.invoiceninja.com/api/v1/invoices -H "Content-Type:application/json" -d '{"client_id“:“14",
"invoice_items":[{"id": 160,"product_key": "test","account_key": "gFckhMII5vsv4WzLzuvAIbJRj41kVD2i","user_id": 62773, "notes": "test","cost": 10,"qty": 1, "tax_name": "","tax_rate": 0}]}' -H "X-Ninja-Token:OURTOKEN" -H "X-Requested-With: XMLHttpRequest"

Error:
{“email”:[“The email field is required when client id is not present.”],“client_id”:[“The client id field is required when email is not present.”]}

Any idea how to fix that?

Thank you and Cheers from Vienna

Leo

The quotes around client_id:14 in your second request look off

Argghhhh. Thank you. :slight_smile: That was the problem.