tcaron
March 4, 2018, 10:46pm
1
Hello,
What is the endpoint and the required fields for creating quotes and let them as draft?
I have tried to send a POST request to https://app.invoiceninja.com/api/v1/invoices and set these fields
"customTextValue1" to "Invoicing from $dateInit to $dateEnd", "auto_bill" to 1, "invoice_date" to LocalDate.now(), "invoice_items" to gson.toJson(invoiceItems), "terms" to terms, "entityType" to "quote", "public_id" to 0, "is_public" to false, "is_recurring" to 0, "is_quote" to 1 <code></code>
But I am getting Internal Server Error
from the API
hillel
March 4, 2018, 10:49pm
2
I think the problem may be how you’re encoding the invoice_items property, the app is expecting an array not a JSON string.
Note: some of the fields you’re including can’t be set for quotes: ie, auto_bill, public_id, entityType
tcaron
March 4, 2018, 10:56pm
3
invoice_items look like "invoice_items": [{"product_key":"Traffic","notes":"Installs","cost":1.41,"qty":28.0}]
If these fields from your note are not required, how I specified it’s a quote then?
hillel
March 4, 2018, 10:58pm
4
The looks ok, can you post the full request?
You just need to set is_quote to 1.
david
March 4, 2018, 10:59pm
5
invoice_date format should equal yyyy-MM-dd
tcaron
March 4, 2018, 11:40pm
6
This is what I send
{
"client_id":"55",
"custom_text_value1":"Invoicing from 2018-02-01 to 2018-02-28",
"auto_bill":1,
"invoice_date":"2018-03-05",
"invoice_items":[
{
"product_key":"Traffic",
"notes":"Mobile Installs - 0",
"cost":1.41,
"qty":28.0
},
{
"product_key":"Traffic",
"notes":"Mobile Installs - 1",
"cost":1.28,
"qty":4.0
},
{
"product_key":"Traffic",
"notes":"Mobile Installs - 2",
"cost":1.41,
"qty":4.0
},
{
"product_key":"Traffic",
"notes":"Mobile Installs- 3",
"cost":1.28,
"qty":18.0
}
],
"private_notes":"GENERATE AUTOMATICALLY",
"terms":"our terms",
"is_quote":1
}
And I’m now getting forbidden as an error form the API.
david
March 4, 2018, 11:44pm
7
What headers are you sending?
I believe at a minimum you will need
X-Ninja-Token
tcaron
March 4, 2018, 11:47pm
8
Yes I send the token. And it’s the right one since it’s working when I ask for the clients.
hillel
March 5, 2018, 2:57am
9
I’m not sure, it’s working for me testing with cURL.
curl -X POST ninja.test/api/v1/invoices -H "Content-Type:application/json" \
-H "X-Requested-With: XMLHttpRequest" \
-d '{
"client_id":"10",
"custom_text_value1":"Invoicing from 2018-02-01 to 2018-02-28",
"auto_bill":1,
"invoice_date":"2018-03-05",
"invoice_items":[
{
"product_key":"Traffic",
"notes":"Mobile Installs - 0",
"cost":1.41,
"qty":28.0
},
{
"product_key":"Traffic",
"notes":"Mobile Installs - 1",
"cost":1.28,
"qty":4.0
},
{
"product_key":"Traffic",
"notes":"Mobile Installs - 2",
"cost":1.41,
"qty":4.0
},
{
"product_key":"Traffic",
"notes":"Mobile Installs- 3",
"cost":1.28,
"qty":18.0
}
],
"private_notes":"GENERATE AUTOMATICALLY",
"terms":"our terms",
"is_quote":1
}' \
-H "X-Ninja-Token: TOKEN"
system
July 13, 2018, 3:01pm
10
Hello,
Don’t know where to start. Would like to integrate onlinecheckwriter.com - check printing software with invoice ninja
david
July 13, 2018, 5:55pm
11
hillel
July 14, 2018, 10:26am
12
There’s some additional info here: http://docs.invoiceninja.com/en/latest/api.html
If you need any help getting it working let us know…