Forum Discussion
Anonymous
5 years agoSee if this gets you started. The simplest HTTP get in Groovy can be done like this:
import com.santaba.agent.groovyapi.http.* my_url = "http://myurl.com" println(new URL(my_url).getText()) return 0
That assumes no authentication though, so it likely won't do. For that, take a look at https://github.com/sweenig/monitoring-recipes/blob/master/DataSources/Groovy/HTTP/Groovy_HTTP_GET_with_BasicAuth.groovy. This example also shows how to convert the response from JSON into a Groovy map. Having it as a Groovy map allows you to access specific elements in the returned data.
Related Content
- 5 years ago
- 8 months ago
- 9 months ago