Create PDF of a query through API template

In looking at this great resource linked to by Retool it seems to do exactly what I am looking for: take a table of data and populate it into a PDF template and generate the PDF.
Creating PDFs in Retool with

However I'm getting stuck on just building out the process to pass information to Fairly new to everything in Retool but I'll do my best to explain...

I have a query in Retool that contains information on all our survey specifications including the specification table name within the database. So if you click on Survey #1 and the name of that table in the database is survey_1 the query below called selectedSpecExport looks like this:

select * from "spec".{{ variable0 }}
would be...
select * from "spec".survey_1

And it contains the columns I need to pass along to the PDF:
question_id, question_text, construct

This query will populate a table within Retool just fine.

From here, it all falls apart. The guide above while helpful sort of skips over some things or doesn't provide clarity for my use case. In their example they appear to just be pulling a value from a component named {{companyAddress.value}} and assigning it as the value for the company_address key passed via JSON. That seems easy enough but there are dozens of rows that are generated via the query above and in trying to place values into the key pairs it says it cannot find the resource or throws any # of errors, none of which really make sense to me. I think the problem is that I am unsure how to reference the columns in that query to pass along via JSON and it's made more complicated because it's really table/array I am passing with multiple rows, not a single value typed into a component like in the example linked to above.

Hopefully that's not too confusing but the basic gist is that I need to take the data from a query in a Retool application and pass each row from that query on to so it will generate a PDF that contains all of the data from that query.

Any help or pointing me in the right direction would be much appreciated!

Are the errors happening in Retool or in the API request? Can you give a sample of the query data and API query setup? It's a little bit hard to tell without seeing what you're doing.

It sounds like you need to determine A. What form your query data is in within Retool and B. What form the PDF template is expecting the request data to take. If the errors are happening in Retool then stop and take a look at A. If they're happening at the request then it sounds more like B is your issue.

Hi there and thanks for your reply.

I'll post a series of screenshots here to give an idea of what I'm doing.

This is the resource/query...

Here are the results of the query I feed into a table modalTableStd (not shown but I don't think that matters since it's really just the results of the query I care about) and I selected one of the columns from that query I am looking to send via the API as selected/shown in that modalTableStd

Finally, here is the API as I've started to construct it (template # and API are placeholders). The current value throwing an error is the name of the specification which is pulled from another query that works fine and is a single value, not an array/table. Even that won't work so I'm obviously doing something wrong and as much I'd love to test just sending something via to the API, I can't even get that to work.

Maybe that helps show a bit more of the process...?

Will address some of the other stuff in a bit but I think you may want to remove or edit that image containing the API key. Probably a low-consequence key but still.

Thanks for the concern; I just randomly typed in a value and generic template ID so there's no consequence. But I can post a different photo

Bumping this to the top.

tl;dr I need help getting to work with passing over a table of information as the example does not show how to do so and attempts by myself have failed.

Just managed to do this recently.
Let me put together the walk-through as I understood it.
What tripped me was creating repeating table as well but think I ended up understanding it.
Be back after work and put this up.

This is how I approached implementation.
First, I got to template the data that the document will comprise of. The table was tricky but I just copied the sample file and adjusted it to my test case's need

Here I have two tables with the code to work through the items and some totals values
The output is as below

Now for the JSON to drive this, sample in the template is

The tables covered by children and pay

Back to retool, I have the data derived from tables as well as some single fields

Within this sidebar, I call the query to run report.

pdf trigger

sample: when you expand out children data
[{"id":14,"name":"Ann-Mary Nelson","dob":"2020-03-25","parentID":27,"gender":"girl","enrollDate":"2024-03-15"},{"id":15,"name":"Juliet Nelson","dob":"2020-03-25","parentID":27,"gender":"girl","enrollDate":"2024-03-15"},{"id":16,"name":"Patrick Nelson","dob":"2021-05-19","parentID":27,"gender":"boy","enrollDate":"2024-02-12"}]
sample: when you expand out pay data
[{"id":2,"parentID":3,"childID":1,"payDate":"2024-02-27","schedule":"Jan,Feb,Mar","comment":"Transport","payAmount":75},{"id":3,"parentID":3,"childID":1,"payDate":"2024-02-26","schedule":"Apr,May,Jun","comment":"SunScreen","payAmount":16},{"id":5,"parentID":3,"childID":1,"payDate":"2024-03-06","schedule":"Jan,Feb,Mar","comment":"additional play cover","payAmount":17},{"id":6,"parentID":3,"childID":1,"payDate":"2024-03-06","schedule":"Jan,Feb,Mar","comment":"additional play cover","payAmount":17},{"id":14,"parentID":3,"childID":2,"payDate":"2024-03-09","schedule":"Jan,Feb,Mar","comment":"top-up","payAmount":48},{"id":15,"parentID":3,"childID":1,"payDate":"2024-03-13","schedule":"Jan,Feb,Mar","comment":"Transport","payAmount":65},{"id":18,"parentID":3,"childID":1,"payDate":"2024-03-15","schedule":"Jan,Feb,Mar","comment":"test","payAmount":4},{"id":19,"parentID":3,"childID":2,"payDate":"2024-03-15","schedule":"Jan,Feb,Mar","comment":"for child 2","payAmount":6},{"id":20,"parentID":3,"childID":1,"payDate":"2024-03-16","schedule":"Jan,Feb,Mar","comment":"school transport cover","payAmount":17}]

and of course on the REST API, think you covered this OK.
Hope that helps.