I have an API endpoint that returns base64 encoded data. Other questions posted here indicate that making a rest api call, and having the pdf component consume the resulting data is the way to go. Unfortunately, even though the app I want to replace with Retool can consume this data, and parsing it with various online tools works fine also, Retool only gives me one of two errors:
If I set the PDF control to consume just data.base64Data, I get "No PDF File specified", if I use the entire json returned from the API. I get "PDF cannot be loaded".
Incidentally, the json the rest call I use returns is typically like this:
{"name": "letter",
"type": "application/pdf",
"sizeBytes": 27148,
"base64Data": (long base64 string that I'm not even allowed to upload separately, so use your imagination)
}
I've tried a bunch of variations for setting this that I've seen in other posts, and am at the point where I think it must be something about the PDFs I generate. Is there some way I can get a better sense of what's going on in the PDF component when it sees an error, on the off chance I can change things in the its API, as opposed to giving up on using Retool for this?
If that doesn't work, it's likely that the PDF isn't correctly encoded in base64.
Should the PDF display correctly, you can proceed to link the output of your query. For instance, if your query is named getPDF, you would use {{ getPDF.data.base64Data }} in the PDF component's File URL field.
That is a big help. I wouldn't have thought of pasting the text directly into the url field, but it does display the pdf. I can figure out what's goin on from there. Thanks.
So, it looks like the base64 PDF data I get back from calling the api directly is different than what I am getting through retool. I was barking up the wrong tree completely.
... it looks like my base64 encoded pdf data was encoded again when returned through Retool, and I just had to decode. Thanks again for getting me on the right track.