【问题标题】:calling jasper report rest api through node js通过node js调用jasper report rest api
【发布时间】:2015-04-14 05:24:33
【问题描述】:

我对碧玉报告的概念非常陌生。我的团队已经在 jasperserver 中构建了一些报告。我唯一需要的就是打电话报告。从节点服务器。我尝试了Jasper Rest API, run a report的代码

 router.get('/', function(req, res, next) {

    request.post({url: "http://localhost:3030/jasperserver/rest/login", 
        qs: {j_username: "jasperadmin", j_password: "jasperadmin"}},
        function(err, res, body) {
            if(err) {
                return console.error(err);
            }
            else{
            request.get("http://localhost:3030/jasperserver/rest_v2/reports/SampleQueryReport.pdf",
                function (error, response, body1) {

                    if (!error) {
                          console.log("downloading")
                    }
                    else{
                        console.log(response.statusCode);
                        console.log(error);
                    }
            })
        }
    });


});

我想获取 pdf 格式的报告。但是当我尝试这段代码时,我得到了 401 未经授权的错误。 我正在使用 express js,node js, npm 模块请求,我在 app.js 中全局声明。 但是我可以通过 url 直接使用这个凭据登录到 jasper 软件。

【问题讨论】:

    标签: node.js express jasper-reports jasperserver


    【解决方案1】:

    我明白问题出在哪里。它显示未经授权的错误,因为在第二个请求中它没有 cookie。即在第一次请求登录时发生并生成 cookie。在第二个请求中没有传递。因此,当我通过该请求传递 cookie 时,它​​起作用了。我的错。

    【讨论】:

      猜你喜欢
      • 2017-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-20
      • 1970-01-01
      • 2020-09-19
      • 1970-01-01
      相关资源
      最近更新 更多