Reputation: 526
Groovy RestClient throw the following Error when Getting the List of Object
this is the code
List<Code> codeList = restClient.get(path:"codes",headers: [Accept: 'application/json'])
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'groovyx.net.http.HttpResponseDecorator@7526515b' with class 'groovyx.net.http.HttpResponseDecorator' to class 'java.util.List'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
Upvotes: 0
Views: 724
Reputation: 526
After changing the code like below ,its working fine
def codeList = restClient.get(path:"codes",headers: [Accept: 'application/json'])
List<Code> codes = codeList.data
Upvotes: 1