我在JasperReports Server上创建了一个Jasper报告。如果我在管理员网页中单击它,则会正确生成报告(首先查询我的数据库)并进行渲染。我还想通过/ reportExecutions REST调用来运行报告,但我无法让它工作。我正在使用以下代码发出POST请求:
String xml = ""
+ "<reportExecutionRequest>"
+ "..."
+ "</reportExecutionRequest>";
HttpPost post = new HttpPost(
new URI("http://localhost:8080/rest_v2/reportExecutions"));
post.setHeader("Content-Type", "application/xml");
post.setEntity(new StringEntity(xml));
HttpResponse response = client.execute(post);
即使我在POST标头中将内容类型指定为“application / xml”,我的响应总是给出415不支持的媒体类型错误。如果我查看JasperReports服务器的Java堆栈跟踪输出,它会指示以下内容:
Caused by: com.sun.jersey.api.MessageException:
A message body reader for Java class
com.jaspersoft.jasperserver.jaxrs.report.
ReportExecutionRequest, and Java type class
com.jaspersoft.jasperserver.jaxrs.report.ReportExecutionRequest,
and MIME media type application/octet-stream was not found.
因此,它看起来正在接收内容类型为“application / octet-stream”的内容,因为它无法找到消息正文阅读器。我有什么想法吗?
感谢。