Hello,
is there an option to add documents inclusive the document file via api?
https://app.invoiceninja.com/api-docs#!/document/post_documents
Thanks,
Michael
Hello,
is there an option to add documents inclusive the document file via api?
https://app.invoiceninja.com/api-docs#!/document/post_documents
Thanks,
Michael
The API supports it, it’s used by our mobile apps.
You need to send a post request to https://app.invoiceninja.com/api/v1/documents
Note: this feature requires our enterprise plan.
Hi Hillel,
thanks for the fast response! I currently use the self hosted version, but I don’t understand how to include the filecontent in the post request!?
{
“id”: 1,
“name”: “Test”,
“type”: “CSV”,
“invoice_id”: 1,
“updated_at”: 1451160233,
“archived_at”: 1451160233
}
Thanks,
Michael
From reviewing the code it looks like you need to set file
and invoice_id
(or expense_id
)
Note: the data should be sent as a multipart/form-data request.
http://docs.guzzlephp.org/en/latest/quickstart.html#sending-form-files
I currently have no idea how to post the documents via Api. Do you have an real life example for me, maybe with php-curl or with phphttpclient.com?
curl -X POST ninja.dev/api/v1/documents -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest" -F "file=@/path/to/file"
I can’t find the way to push Documents via API. Can I buy commercial support for this?
For me the best way would be to have an complete example with cmd curl or php curl for PHP 7.0.
The comment above has a complete working curl example.
You can hire help here: https://github.com/invoiceninja/invoiceninja#third-party-developers
I tried it on the cmd and the document is uploaded, but how could I additionaly transfer the invoice_id?
http://osxdaily.com/2017/01/30/curl-post-request-command-line-syntax/
My first try was to update the document after creating it, but there is no PUT Call.
Here’s what you’d add when using curl
-H "Content-Type:application/json" -d '{"invoice_id":1}'
This way don’t works :(.
“Warning: You can only select one HTTP request method! You asked for both POST
Warning: (-d, --data) and multipart formpost (-F, --form).”
Try using ninja.dev/api/v1/documents?invoice_id=1
as the URL
the GET Link with invoice_id was the solution! Thanks!
Great to hear!
with httpful http://phphttpclient.com/ the call is:
$url = 'ninja.dev/api/v1/documents?invoice_id=1;
$response = \Httpful\Request::post($url)
->addHeader(‘X-Ninja-Token’, ‘TOKEN’)
->addHeader(‘Requested-With’, ‘XMLHttpRequest’)
->attach([‘file’ => $pdfFile])
->send();
I know this is an old post, but just wanted to thank you for this answer, it worked great for me.