title: calling jasper report rest api through node js
body: <p>I am very much new to the concept of jasper report. My team had already build some reports in jasperserver. the only thing I needed is to call reports. From a node server. I tried code from <a href="https://stackoverflow.com/questions/9538038/jasper-rest-api-run-a-report/19660886#comment47383216_19660886">Jasper Rest API, run a report</a> </p>
  
  <pre><code> router.get('/', function(req, res, next) {
  
      request.post({url: "http://localhost:3030/jasperserver/rest/login", 
          qs: {j_username: "jasperadmin", j_password: "jasperadmin"}},
          function(err, res, body) {
              if(err) {
                  return console.error(err);
              }
              else{
              request.get("http://localhost:3030/jasperserver/rest_v2/reports/SampleQueryReport.pdf",
                  function (error, response, body1) {
  
                      if (!error) {
                            console.log("downloading")
                      }
                      else{
                          console.log(response.statusCode);
                          console.log(error);
                      }
              })
          }
      });
  
  
  });
  </code></pre>
  
  <p>I want to get the report in pdf format. But when I tried this code am getting 401 unauthorized error. 
  I am using express js,node js,
  npm module request, which I globally declared in app.js. 
  But I can log to the jasper soft directly with this credentials through url.</p>