Groovy Action - Call Rest API


#1

Does anyone have any experience making an action with groovy that would fire a call out to a REST endpoint?

Right now we get alerts from our Proofpoint Email Spam service that has just basic info for us to understand whats happening. If you want the full details you can click a link in the alert email that brings you to all of the pertinent info needed to follow up with an end user.

Proofpoint offers an REST API endpoint that you can interface with to pull down all of these details as well.

TLDR; I need a groovy script thatcan query a REST API and parse for certain bits of information.


#2

Take a look at the JIRA integration script for an example of how to do a REST API call and parse the output.


#3

Thank you @berkay. I was actually looking at the Jira integration before, just wan’t sure if that was the route to take. I started pulling over the necessary bits I think I’ll need.

When I fire the action I am getting a MissingMethodException.

Do I need to make sure that there are Jar files in my Lib folder to lineup with my import statements? If so where would I find them?

WARN: Exception occurred while executing script [proofPoint.groovy]. Reason: groovy.lang.MissingMethodException: No signature of method: proofPoint.createHttpClient() is applicable for argument types: () values: []
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: proofPoint.createHttpClient() is applicable for argument types: () values: []

#4

Hi,

You need the jar files to execute the groovy script. In order to get those, you can download the marid package that we created for Jira integration. You can also find other packages that we prepared for different integrations from here.

You can also use our Java SDK which provides a Java API for OpsGenie services, making it easier for Java developers to build applications that integrate with OpsGenie. For more information, please see OpsGenie Java API document.