Jump to content
Changes to the Jaspersoft community edition download ×

Jasper web services v2 PDF download not working


Recommended Posts

I want to download jasper report (pdf) using jasper web services v2 with Node.js & express.js. pl check my code below.


In this code i have got 200 but i cant download the PDF file.


// get const

const Express = require('express');

var  Request =  require('request'),

     QueryString = require('querystring'),

     baseRequest = Request.defaults({

        jar: true

    });

 

// define 

 

var Loginurl='http://ipaddress/jasperserver/rest/login?j_username=******&j_password=*****'; 

var setpath = 'http://ipaddress/jasperserver/rest_v2/resources/reports/interactive/CustomersReport';

 

var app = Express();

 

// Get PDF

app.get('/getpdf',(req,res)=>{

 

baseRequest.post({url:Loginurl},(error,response,body)=>{

    if(response.body ==="Unauthorized")

    {

       res.send(JSON.stringify({result:'check username and password',Message:'Unauthorized',status:false}));

    }else if(response.body ==="License expired or otherwise not valid"){

      res.send(JSON.stringify({result:'Not Valid',Message:'License expired or otherwise not valid',status:false}));

    }else{

   

             baseRequest.get({url:setpath,"content-type": "application/Report+json",body: '<resourceDescriptor></resourceDescriptor> '},(error,response,body)=>{

              res.send(response);

       }); 

       

    }

 

});

 

 

});

 


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...