Groovy (2.5.4+)

Prerequisites

You should have a running environment for Java 11 (or later) ready set up. Additionally Groovy version 2.5.4 or above should be running for the sample code to work. Check your installation by printing the version.

(base) ~ % groovy --version
Groovy Version: 3.0.9 JVM: 11.0.13 Vendor: BellSoft OS: Mac OS X

Plain request

Using native Groovy we can jump into groovyConsole or groovysh to assemble and send a request like so:

def jsonSlurper = new groovy.json.JsonSlurper()
def response

def request = new URL("https://api.football-data.org/v4/competitions").openConnection()
// set http headers for response format and authentication
request.setRequestProperty("Content-Type", "application/json")
request.setRequestProperty("X-Auth-Token", "UR_TOKEN")

if (request.responseCode.equals(200)) {
    def rawResponse = request.getInputStream().getText()
    response = jsonSlurper.parseText(rawResponse)
}

// print all competition names you are subscribed to
response.competitions.each {
  println it.name
}