Not able to update invoice public notes using API

I am using the self hosted version of IN but I don’t seem to be able to do the following with a PUT call, if I do a POST with the same information, I am able to create a new invoice:

curl -X PUT
http://yoalmadriz.com/ninja/public/api/v1/invoices
-H ‘Cache-Control: no-cache’
-H ‘Content-Type: application/json’
-H ‘Postman-Token: 181c82f0-698a-48a1-ae3a-3d17d98986ae’
-H ‘X-Ninja-Token: mytoken’
-H ‘X-Requested-With: XMLHttpRequest’
-d ‘{
“id”: 2,
“client_id”: 1,
“public_notes”: “hola”
}’

There is nothing in the error log, I get 405 METHODNOTALLOWED in Postman and a page ‘Whoops, looks like something went wrong.’. My version is 4.5.4.

Are there any restrictions for PUT in the sefl hosted version? Do I need to provide any special set of data? I also tried with id only and did not work.

Thanks!

A put request would need to include the id in the URL, ie. api/v1/invoices/1

Thanks for the quick response, I just tried it with the id in the URL and I got Internal Server Error and the following in the error log:

[2018-09-26 04:36:22] production.ERROR: ErrorException [0] : /home/bhokp8bj6m4e/public_html/ninja/app/Ninja/Repositories/InvoiceRepository.php [Line 545] => Undefined index: invoice_items {“context”:“PHP”,“user_id”:1,“account_id”:“1”,“user_name”:“Yoal Madriz”,“method”:“PUT”,“user_agent”:“PostmanRuntime/7.3.0”,“locale”:“en”,“ip”:“186.32.177.243”,“count”:1,“is_console”:“no”,“is_api”:“yes”,“db_server”:“mysql”,“url”:“api/v1/invoices/2”} []

And I know the invoice ID is valid because if use GET with the same URL you just gave me, it works.

To update an invoice you need to send the current data, you’re seeing the error because you aren’t sending invoice_items.

You are a genius, that made the trick, thanks a lot for your support! Greetings from Costa Rica!!!

Glad to hear it’s working!

Are you able to provide the full code that you got this to work with?