Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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);
- });
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement