API endpoints and required fields for quotes

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

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

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?

The looks ok, can you post the full request?

You just need to set is_quote to 1.

invoice_date format should equal yyyy-MM-dd

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.

What headers are you sending?

I believe at a minimum you will need

X-Ninja-Token

Yes I send the token. And it’s the right one since it’s working when I ask for the clients.

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"

Hello,
Don’t know where to start. Would like to integrate onlinecheckwriter.com - check printing software with invoice ninja

ocw:

Our API is documented here:

https://app.invoiceninja.com/api-docs

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…