Hey team, anyone that can help me with this questi...
# gooddata-cloud
e
f
Hi Evangelos, could you tell me a bit more about the context of this question? The original thread you linked was all about using the
export_pdf
method, or the API to export a Dashboard. Are you looking for the same use-case? Since then, our developers have released the Tabular exports to PDF feature, which is described on this Apiary Entry, and is a lot more detailed on how to structure the body of the JSON. Would you kindly take a look there?
e
Hey @Francisco Antunes, thanks for the reply. My use case is that I have a dashboard that I want to export in PDF format using different filter values every time due to the fact that I want to send it to different clients. What I don't get in the documentation is how should I structure the
metadata
field for this use case. What type of object is expected withing the
metadata
field: the filter context id along with the local identifier of the filter? Not sure if my point is clear, but I can provide an example if needed.
👀 1
f
Thanks for explaining! I do have an example API call that should help you out:
Copy code
curl -X POST https://{{baseUrl}}/api/v1/actions/workspaces/894c6276e4bd41d89084db8a6e8688a8/export/visual -H "Authorization: Bearer xxxxx" -H 'Content-type: application/json' -d '{"fileName":"Different filter","dashboardId":"4fb95767-9368-4536-a890-f6119086e577","metadata":{"filters":[{"dateFilter":{"from":-1,"granularity":"GDC.time.year","to":-1,"type":"relative"}},{"attributeFilter":{"attributeElements":{"uris":["Jasmine"]},"displayForm":{"identifier":"NAME","type":"displayForm"},"negativeSelection":false,"localIdentifier":"465a183c6cab4bf4a
d9783760cc21bc0","selectionMode":"multi"}}]}}'
It’s basically the same syntax as it would be on the dashboard’s JSON definition. So you can easily trial-and-error it by modifying a dashboard to have the filters you would want to use, and call the Get a Dashboard endpoint - it will give you the filter IDs and proper syntax to apply on the Visual Export API calls 🙂
e
Thanks for the detailed reply @Francisco Antunes, will get back to you if I face any difficulties🙏
Hey @Francisco Antunes, even though I tried to create the export based on your example, I couldn't. My dashboard entity looks like this:
Copy code
{
  "data": {
    "id": "6a7f0763-bb43-495e-9445-6ae260d90198",
    "type": "analyticalDashboard",
    "attributes": {
      "title": "Self invoice attachment",
      "description": "",
      "content": {
        "dateFilterConfig": {
          "filterName": "",
          "mode": "readonly"
        },
        "filterContextRef": {
          "identifier": {
            "id": "924d988f-ec4c-4c14-ab5c-59597fcc4885",
            "type": "filterContext"
          }
        },
        "layout": {},
        "version": "2"
      },
      "createdAt": "2025-04-08 00:53",
      "modifiedAt": "2025-04-14 17:35"
    },
    "meta": {
      "origin": {
        "originType": "NATIVE",
        "originId": "dev.master"
      }
    }
  }
}
So I tried to send a export PDF request using the body below and I got an accepted status (201 Created). But when I try to access the PDF, I get 202 Accepted without the PDF file appearing.
Copy code
{
  "dashboardId": "6a7f0763-bb43-495e-9445-6ae260d90198",
  "fileName": "attachment.pdf",
  "metadata": {
    "filters": [
      {
        "dateFilter": {
          "from": "2024-11-01 00:00",
          "granularity": "GDC.time.date",
          "to": "2024-11-30 23:59",
          "type": "absolute"
        }
      },
      {
        "attributeFilter": {
          "attributeElements": {
            "uris": [
              "Ästad Vingård"
            ]
          },
          "displayForm": {
            "identifier": {
              "id": "D_SITES.SITE_NAME",
              "type": "label"
            }
          },
          "localIdentifier": "D_SITES.SITE_NAME_1_attributeFilter",
          "negativeSelection": false,
          "selectionMode": "multi"
        }
      }
    ]
  }
}
My guess is that the problem is associated with the fact that the dashboard doesn't have direct filters but
filterContext
instead. Any ideas of how I can overcome this? 😊
f
The syntax looks correct. The
202
status code indicates that the resource is still processing the request (i.e.: generating the PDF). Have you tried giving it more time and polling it again later?
e
Yes, I tried a couple of times after some time and I'm still getting 202. At the end, I'm getting a message that the resource isn't available anymore.
f
Okay, thank you for confirming 🙂 I’ll run some tests on my end and update you soon!
e
Thanks 🙏
f
I was able to get the export to run with a filter, but the PDF ended up empty - I’ll keep testing. I tried the syntax from a Visualization Object (a report) instead of the Dashboard (as opposed to what I said before - you are right, the syntax from the Dashboard endpoint didn’t match properly). See the example:
Copy code
{
  "dashboardId": "092929af-375a-4e9c-964f-2add8cdbd259",
  "fileName": "PDF-export-test",
  "metadata": {
    "filters": [
      {
        "relativeDateFilter": {
          "dataSet": {
            "identifier": {
              "id": "date",
              "type": "dataset"
            }
          },
          "granularity": "GDC.time.year",
          "from": 0,
          "to": 0
        }
      }
    ]
  }
}
Note that the filename doesn’t contain
.pdf
. Would you kindly give something similar a try? With a very simple filter - and let me know how it goes 😉
e
Yes, I'll give it a shot with a visualization from the same dashboard and let you know 😊
Hey @Francisco Antunes, just wanted to let you know that I found a solution through this message: https://gooddataconnect.slack.com/archives/C04S1MSLEAW/p1745507976914389?thread_ts=1722000154.074259&cid=C04S1MSLEAW So all good from my side 😊
f
That’s fantastic news! Thanks for sharing the solution as well, I’ll make note of it for sure 🙂
🙌 1