I’d like to add an API endpoint to my extension to support a simple action via a REST call.
I can’t work out what is the best way to achieve this, either with the standard tooling with REST2 framework or a quick and hacky alternative. Is there any example code of adding a custom rest endpoint?
Is this for one user or many different possible users? I wonder if it would be easier to create an RT scrip that runs on some custom field being set on a transaction or ticket and the API call is what kicks off that scrip, where it is much easier to control the Perl code being run.
The other option would be to create a new route in RTs /local/html directory and have that be your new “REST” route, if you’re familiar with Mason Perl syntax that would be rather fast to test implement!
Its actually based on the time tracking extension - adding an endpoint for the ‘AdminTimesheets’ functionality:
So wouldn’t really want to go to that level of transaction custom field action. I suppose the html route might be a decent option - was just looking to use RT helpers such that the response types with json plain text etc.
It sounds like you’re trying to set time worked on a transaction via REST, looking under the hood I think the best way to do that is set the Actor transaction custom field to the user who is doing the work and adding the time worked.
You’ll have to do some testing but I think that should work!