Unable to find specified template or user doesnt have permissions to read it



  • We have switched to jsreport-core and are now getting the error message as seen below.

    Here is the server.js

    var jsreport = require('jsreport-core')();
    var express = require('express');
    
    var app = express();
    app.use(express.json());
    
    jsreport.use(require('jsreport-express')({app: app}));
    jsreport.use(require('jsreport-phantom-pdf')());
    jsreport.use(require('jsreport-jsrender')());
    jsreport.use(require('jsreport-templates')());
    jsreport.use(require('jsreport-fs-store')());
    
    jsreport.init().catch((e) => {
      // error during startup
      console.error('Error during startup');
      console.error(e.stack);
      process.exit(1);
    });
    
    // health check
    app.get('/health', (req, res) => {
      res.sendStatus(200);
    })
    
    // report posting
    app.post('/api/report', function(req,res) {
      console.log('\n');
      console.log(req.body);
      console.log('\n');
      jsreport.render(req.body).then(function(res) {
        console.log(res.content.toString());
      }).catch((e) => {
        // error during render
        console.error('Error during render');
        console.error(e.stack);
      })
    });
    
    app.listen(5489);
    

    Post (I have tried using both shortid and name to ensure that it is correct):

    {
      "template": {
    	"shortid": "HkVI7bmHE"
      },
      "data": {
        ...
      }
    }
    

    Error:

    Error: Unable to find specified template or user doesnt have permissions to read it: Main
        at module.exports (/app/node_modules/jsreport-core/lib/util/createError.js:11:13)
        at Reporter.createError (/app/node_modules/jsreport-core/lib/reporter.js:265:12)
        at AsyncFunction.<anonymous> (/app/node_modules/jsreport-templates/lib/templates.js:142:20)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    


  • Please submit your question to the jsreport-core repository.
    This forum is primarily about the whole jsreport and troubleshooting core won't be interesting for the majority of the users here.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.