Using data from POST request instead of local file

  • Hi guys,

    I want to invoke jsreport render by passing the data like this:
    The problem is that, if I pass the data, it still uses the data from local data file. How can I configure jsreport to use the one that is being passed through POST request?

  • The data passed through the request body has always the priority over the references sample data in the studio.
    Please try to share some code snippets so we can see what could be wrong.

  • I am testing it locally with postman app while my jsreport is running. It renders the report but with data from a local file...
    Here is my request body from postman:

    POST /api/report HTTP/1.1
    Host: localhost:5488
    Content-Type: application/json
    User-Agent: PostmanRuntime/7.20.1
    Accept: */*
    Cache-Control: no-cache
    Postman-Token: e1dc0fd9-d6dc-4204-b2b9-9c2ccbb9b827,5b88bbe6-0abf-43fd-b5c3-84ae03dc2a46
    Host: localhost:5488
    Accept-Encoding: gzip, deflate
    Content-Length: 171725
    Cookie: render-complete=true
    Connection: keep-alive
    cache-control: no-cache
        "template": {
            "shortid": "B1QSGTZSr",
            "data": {...}

    What else could be helpful to share with you?

  • You should place data prop to the root level of the body. See it again here

          "template": { "name" : "my template"  },
          "data" : { ... },
          "options": { "reports": { "save": true } }

  • That's it. Thanks Jan!

Log in to reply

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