Calling REST API from within plugin

Added by Mayama Takeshi 2 months ago

Hello, I am new to rails development.
I am trying to write a redmine plugin and I am trying to add a note to an issue using ajax (issues/ID.json, sending PUT request with data as {"issue": {"notes": "some notes"}} ) from a defaced issues#show view.
However, the REST API is replying with '401 Unauthorized' (after which the browser pops up a form for insertion of user/pass and after that, the request is resent and accepted) but the user is logged in so I would expect authorization/authentication to be done by session cookie (after user/pass insertion, subsequent ajax requests will not trigger 401 anymore).

I notice this problem doesn't happen when the user clicks on the delete-note icon. Then I realized the ajax request triggered by the delete-note icon uses URL "/journals/ID?journal="
which is not listed as a resource in Rest_api.
So, should I consider this a bug in REST API or am I supposed to create a specific resource to deal with my ajax request (not very DRY).