Jasper Rest API,运行报告 [英] Jasper Rest API, run a report

查看:75
本文介绍了Jasper Rest API,运行报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于使用Jasper Rest API,我目前正在尝试生成报告并获取输出(PDF),文档的相关部分为

I am currently trying to run a report thanks to Jasper Rest API and get the output (PDF), the interessant part of the doc is here

所以我尝试了这个:http://localhost:8080/jasperserver/rest/report/reports/samples/report_mongodb_new_basic

知道我的报告在报告/样本中,并且其资源ID为:report_mongodb_new_basic

Knowing that my report is in reports/samples and its Resource ID is : report_mongodb_new_basic

所以我仍然尝试使用nodejs运行它,这是我的代码: (请求是此处可用的nodejs模块)

So I still tried to run it with nodejs here is my code : (request is a nodejs module available here )

登录:

var request = require("request");   
request.post({url: "http://localhost:8080/jasperserver/rest/login", 
qs: {j_username: "jasperadmin", j_password: "jasperadmin"}},
function(err, res, body) {
    if(err) {
        return console.error(err);
    }

登录后,如文档所示,我需要执行PUT请求才能运行报告:

After login, as the doc show I need to do a PUT request to run the report :

     request.put("http://localhost:8080/jasperserver/rest
     /report/reports/samples/report_mongodb_new_basic")

这当然是行不通的,即使我直接使用 Firefox ,它说

This isn't working of course, even when i directly go on this url with Firefox, it say

"Report not found (uuid not found in session)"

应通过此PUT请求创建uuid

The uuid should be created thanks to this PUT request

那么URL的良好语法和PUT请求获取 uuid 的良好语法是什么?如果可能的话,带GET的pdf是什么?

So what is the good syntax of the URL and the good syntax of a PUT request to get the uuid and after if possible the pdf with a get?

推荐答案

jonny提供了正确的答案.但这是一个更简单的方法,使用REST_v2接口,您可以在单个请求中运行并获取报告输出:

jonny provided a correct answer. But here is a simpler one, using the REST_v2 interface that allows you to run and get a report output in a single request:

        request.get("http://localhost:8080/jasperserver/rest_v2/reports/samples/report_mongodb_new_basic.pdf")

这在网络服务文档的3.2.1节中进行了描述.

这篇关于Jasper Rest API,运行报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆