Complete Example of Accessing The OPEN API From Groovy

Document created by Michael Schaefer on Oct 13, 2016Last modified by Michael Schaefer on Dec 11, 2017
Version 1Show Document
  • View in full screen mode

Below is a simple example of hitting the PAPI endpoint to get a list of Akamai contracts on our account. We have obfuscated our client secret and other security tokens. But you should be able to replace these dummy values with your own and get this work in a short amount of time. Hope this helps others get through this process quicker that we did.


First, here are the Maven dependencies we are using: 





And here is the code: 

import com.akamai.edgegrid.signer.ClientCredential
import com.akamai.edgegrid.signer.EdgeGridV1Signer
import com.akamai.edgegrid.signer.Request

String host = "akab-*****-*****"

ClientCredential credential = ClientCredential.builder()
        .host( host )

Request request = Request.builder()
        .uriWithQuery(URI.create( "https://${credential.getHost()}/papi/v0/contracts/" ))

def restClient = new RESTClient( "https://${credential.getHost()}" )
String auth = new EdgeGridV1Signer().getSignature(request, credential)
restClient.getHeaders().put("authorization", auth)

try {
    def response = restClient.get([path: "/papi/v0/contracts/"])
    assert response != null
catch (Exception e) {


The important thing to note here is how "host" is used. When creating the ClientCredential, they want just the host and not the "https" or the path. However, when building the Request object and the RESTClient objects, they both need the "https" and the Request object needs the full path of the call as well because apparently that is used when signing the request in EdgeGridV1Signer.getSignature(). This is what tripped us up for several days and we found no documentation that explained how this worked. So hopefully, this will help you get started more quickly. Best of luck.



1 person found this helpful