我一直在尝试使用Groovy对JasperReports执行POST但没有成功。
GET工作正常,我可以成功验证。
我无法理解以下代码的问题:
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.JSON
def restV2 = new RESTClient( 'http://localhost:8080/jasperserver-pro/rest_v2/' )
restV2.auth.basic "superuser", "superuser"
def resp = restV2.post(
path : 'organizations',
contentType:JSON,
requestContentType : JSON,
body : [id:'1234567891234',
alias:'FictiefeNet',
tenantName:'FictiefeNet',
tenantDesc:'FictiefeNet B.V.',
theme:'default']
)
输出结果为:
Caught: java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
at groovyx.net.http.EncoderRegistry.encodeJSON(EncoderRegistry.java:301)
at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.encodeBody(HTTPBuilder.java:1268)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:442)
at groovyx.net.http.RESTClient.post(RESTClient.java:141)
at groovyx.net.http.RESTClient$post.call(Unknown Source)
at setOrg.run(setOrg.groovy:7)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
... 6 more
我确信正文格式正确,因为POST调用可以很好地从邮递员处理(Chrome的REST API扩展)。
非常感谢任何帮助!