I'm trying to create a rest endpoint (in ScriptRunner) which uses the mywork-confluence-host-plugin java api
Here's the code :
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.mywork.host.service.LocalNotificationServiceImpl
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.mywork.mywork-confluence-host-plugin")
@PluginModule LocalNotificationServiceImpl notificationService
@BaseScript CustomEndpointDelegate delegate
someEndpoint(httpMethod: "GET", groups: ["someGroup"]) { MultivaluedMap queryParams, String body ->
def notifications = notificationService.findAll("someUsername")
return Response.ok(new JsonBuilder(notifications).toString()).build();
}
However, when i include the @PluginModule annotation, the endpoint in ScriptRunner becomes invalid. When i try to hit the endpoint, I get a 404. In my configuration,
What a valid endpoint looks like in my configuration:
What the endpoint using @PluginModule looks like in my configuration:
Hi Alexander,
Do you have any anomalous output in your logs? Any stacktraces or any other errors perhaps?
@Stephen Cheesley _Adaptavist_ It wasn't outputting any logs so after some troubleshooting i disabled the ScriptRunner plugin, thene re-enabled it and the same code runs just fine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stephen Cheesley _Adaptavist_ after not running the code for a while, it started giving the following error :
{
message: "Cannot invoke method findAll() on null object",
stack-trace: "java.lang.NullPointerException: Cannot invoke method findAll() on null object at Script486$_run_closure1.doCall(Script486.groovy:21) at com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint.doEndpoint(UserCustomScriptEndpoint.groovy:308) at com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint.getUserEndpoint(UserCustomScriptEndpoint.groovy:195) ",
status-code: "INTERNAL_SERVER_ERROR"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version of ScriptRunner are you using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's what the configuration looks like now:
Also , I haven't changed any of the code, or have even updated it from what you see above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using Data Centre or Server?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would recommend updating to the latest version of ScriptRunner as we patched some DC issues for REST endpoints in that release
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ill give that a shot and ill check back here if I still experience the issue - thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Alexander,
Did the upgrade fix your issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't had any issues since I've upgraded - I'll mark this as resolved. Thanks Stephen!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.