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

1

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({
}, function (e, r, body) {
    baseRequest.get({
    }, function (e, r, body) {
        baseRequest.put({
            body: '<resourceDescriptor></resourceDescriptor> '
        }, function (e, r, body) {
            baseRequest.get({
            }, function (e, r, body) {
                console.log(r);
            });
            //console.log(r);
        });
    });
});
 
//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.
 
kessleag's picture
Joined: Oct 7 2014 - 8:35am
Last seen: 5 years 3 weeks ago

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.

kessleag - 5 years 3 weeks ago

1 Answer:

1

Just reading the doc for request - seems that cookies are disabled by default, would jar:true solve the problem? (from https://github.com/mikeal/request)

ernestoo's picture
8924
Joined: Nov 29 2010 - 11:59am
Last seen: 2 years 1 month ago

Okay so creating a new variable called baseRequest and using that in all my statements worked up until the last GET statement, so the "full authentication" error was being caused by cookies being disabled by default.

kessleag - 5 years 3 weeks ago
Feedback
randomness