I'm pretty new in groovy, trying to encode a URL in my first piece of groovy code.
Here is a section of my code:
import java.net.URLEncoder
String url = baseUrl + URLEncoder.encode(parameter);
It looks quite the same as many examples I check online but it throws error as below.
General error during canonicalization: Importing [java.net.URLEncoder] is not allowed
java.lang.SecurityException: Importing [java.net.URLEncoder] is not allowed
I have also tried to use the class directly as illustrated here
String url = baseUrl + java.net.URLEncoder.encode(parameter);
and another version:
String url = baseUrl + URLEncoder.encode(parameter);
both throw me error:
General error during canonicalization: Indirect import checks prevents usage of expression
java.lang.SecurityException: Indirect import checks prevents usage of expression
appreciate if any guru can help clear the doubts.