Pratik Dey
Pratik Dey

Reputation: 21

Facing issue while executing the Groovy code

def hawkClient = new com.wealdtech.hawk.HawkClient.
    Builder()
    .credentials(new com.wealdtech.hawk.HawkCredentials.Builder()
            .keyId("your-hawk-hey-id")
            .key("your-hawk-key")
            .algorithm(Algorithm.SHA256)
            .build())
    .build();

def authorization = hawkClient
    .generateAuthorizationHeader(sampler.getUrl().toURI(), sampler.getMethod(), sampler.getArguments().getArgument(0).getValue())

vars.put('authorization', authorization)

after execute the above code snippet I got some error. like-

org.codehaus.groovy.control.MultipleCompilationErrorsException: 
startup failed:
/home/cg/root/62c2edae2dde2/main.groovy: 1: unexpected token: . @ 
line 1, column 51.
    com.wealdtech.hawk.HawkClient.
                             ^
1 error

can anyone please help me to fix this issue ??

can anyone please help me to fix

Upvotes: 0

Views: 60

Answers (1)

tim_yates
tim_yates

Reputation: 171054

The Groovy parser can't handle newlines as you have it above.

Instead of

def hawkClient = new com.wealdtech.hawk.HawkClient.
    Builder()

You need to use

def hawkClient = new com.wealdtech.hawk.HawkClient.Builder()

So the parser can know what you mean to do

Upvotes: 2

Related Questions