# Kibana report generation - Spring Boot

**URL:** https://discuss.elastic.co/t/kibana-report-generation-spring-boot/357522
**Category:** Kibana
**Created:** [April 16, 2024, 2:04pm UTC](https://discuss.elastic.co/t/kibana-report-generation-spring-boot/357522 "2024-04-16T14:04:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Avijit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avijit/32/133561_2.png) [@Avijit](https://discuss.elastic.co/u/Avijit)
#### Post date: [April 16, 2024, 2:04pm UTC](https://discuss.elastic.co/t/kibana-report-generation-spring-boot/357522/1 "2024-04-16T14:04:58Z")

</div>

I am trying to automatically download the Kibana report in PDF format. Following the documentation here : [Automatically generate reports | Kibana Guide [8.13] | Elastic](https://www.elastic.co/guide/en/kibana/current/automating-report-generation.html)

The issue is, on hitting the path that has been returned by the POST call, it returns JSON data. But I want the PDF to be downloaded and stored at a location.

JSON to PDF seems to be a lengthy process and there's no schema that is fixed for the pdf report json that we will get every time. And apparently it requires schema to be fixed for json to pdf conversion in spring boot.

Any better way to do it?

---

<div class="post-metadata">

### Author: ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)
#### Post date: [April 29, 2024, 3:01pm UTC](https://discuss.elastic.co/t/kibana-report-generation-spring-boot/357522/2 "2024-04-29T15:01:29Z")

</div>

The documentation is clear on how this works:

- Get the POST URL from Kibana for your report
- Call that URL correctly (this depends on your environment) in my case using `curl` would be as:

```bash
currl --user $ELASTIC_USER:$ELASTIC_PASSWORD \
  -XPOST \
  -H "kbn-xsrf:true" \ 
  "${KIBANA_HOST}${KIBANA_REPORT}

```

```json
{
    "path": "/api/reporting/jobs/download/47a25336-c2a2-4d94-88da-0b01566dc42f",
    "job": {
        "id": "47a25336-c2a2-4d94-88da-0b01566dc42f",
        "index": ".reporting-2024-04-28",
        "jobtype": "printable_pdf_v2",
        "created_at": "2024-04-29T14:50:42.420Z",
        "created_by": "elastic",
        "meta": {
            "objectType": "dashboard",
            "layout": "preserve_layout",
            "isDeprecated": false
        },
...
}

```

The JSON returned has a `path` parameter that, concatenated to your Kibana host URL will return your PDF

```bash
curl --user $ELASTIC_USER:$ELASTIC_PASSWORD \
  -XGET \
  -H "kbn-xsrf:true" \
  --output report.pdf \
  "${KIBANA_HOST}/api/reporting/jobs/download/47a25336-c2a2-4d94-88da-0b01566dc42f"

```

So just to reiterate, downloading a report from Kibana is a two-steps process, minding that the first step triggers an async process that may need some time to deliver the report as detailed in the [`503 (Service Unavailable)`](https://www.elastic.co/guide/en/kibana/current/automating-report-generation.html#reporting-response-codes) section.
