groovyjmeterjmeter-pluginsjmeter-5.0groovyshell

Facing issue while executing the groovy code in JMeter


def hawkClient = new com.wealdtech.hawk.HawkClient.Builder()
                                          .credentials(new com.wealdtech.hawk.HawkCredentials.Builder()
                                              .keyId("UB6Vs7U8r45M9")
                                              .key("eFzPNjBgCFAbCFbu5NTxmSkGPYxqXLK3")
                                              .algorithm(Algorithm.sha256)
                                              .build())
                                           .build();
def authorization = hawkClient.generateAuthorizationHeader(sampler.getUrl().toURI(), sampler.getMethod(), sampler.getArguments().getArgument(0).getValue())
vars.put('authorization', authorization)

when I execute this above snippet in JMeter got this error " javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: Algorithm for class: Script47"

can someone please help me to fix it??


Solution

  • You need to add an appropriate import statement to the beginning of your script:

    import com.wealdtech.hawk.HawkCredentials
    

    or just use fully qualified class name:

    .algorithm(com.wealdtech.hawk.HawkCredentials.Algorithm.SHA256)
    

    More information: