Jump to content
We've recently updated our Privacy Statement, available here ×

How do I get the rest api to print out a report using node?


kessleag

Recommended Posts

I'm new to Jasperserver but through multiple iterations I've been able to come up with this: 

//CODE

var request = require("request"),

    qs = require('querystring'),
    url = 'localhost:8080/jasperserver/rest/resource/reports/test/UserReports',
    baseRequest = request.defaults({
        jar: true
    });
baseRequest.post({
    url: "http://localhost:8080/jasperserver/rest/login?j_username=jasperadmin&j_password=jasperadmin"
}, function (e, r, body) {
    baseRequest.get({
        url: 'http://localhost:8080/jasperserver/rest/resource/reports/test/UserReports'
    }, function (e, r, body) {
        baseRequest.put({
            url: 'http://localhost:8080/jasperserver/rest/report/reports/test/UserReports',
            body: '<resourceDescriptor></resourceDescriptor> '
        }, function (e, r, body) {
            baseRequest.get({
                url: 'http://localhost:8080/jasperserver/rest/report/58f342c1-a3a0-4df2-8855-6596deec9883?file=report'
            }, function (e, r, body) {
                console.log®;
            });
            //console.log®;
        });
    });
});
 
//CODE
 
Basically I have my report on Jasper Server and I'm trying to retrieve as a pdf through a Javascript file using node. Everything returns okay and fine except for my GET request at the end. It always returns a "report not found (uuid not found in session)" error, and I am unsure of how to get a uuid that stays constant.
 
Note: The <resourceDescriptor> is there because the actual resourceDescriptor was simply too long and had very janky formatting.
 
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

I did in fact find a solution: It was to use iframe to call the Jasperserver url, this allows me to access all my reports and junk through an external html file. Although I still wish to make this code work because it's been a good learning experience and I want to see this through to the end.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...