Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // get const
  2. const Express = require('express');
  3. var Request = require('request'),
  4. QueryString = require('querystring'),
  5. baseRequest = Request.defaults({
  6. jar: true
  7. });
  8.  
  9. // define
  10.  
  11. var Loginurl='http://ipaddress/jasperserver/rest/login? j_username=******&j_password=*****';
  12. var setpath = 'http://ipaddress/jasperserver/rest_v2/resources/reports/interactive/CustomersReport';
  13.  
  14. var app = Express();
  15.  
  16. // Get PDF
  17. app.get('/getpdf',(req,res)=>{
  18.  
  19. baseRequest.post({url:Loginurl},(error,response,body)=>{
  20. if(response.body ==="Unauthorized")
  21. {
  22. res.send(JSON.stringify({result:'check username and password',Message:'Unauthorized',status:false}));
  23. }else if(response.body ==="License expired or otherwise not valid"){
  24. res.send(JSON.stringify({result:'Not Valid',Message:'License expired or otherwise not valid',status:false}));
  25. }else{
  26.  
  27. baseRequest.get({url:setpath,"content-type": "application/Report+json",body: '<resourceDescriptor></resourceDescriptor> '},(error,response,body)=>{
  28. res.send(response);
  29. });
  30.  
  31. }
  32.  
  33. });
  34.  
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement