Replies: 1 comment
-
After rebooting, and setting the rest call to a "Navigate to" -> "URL" the call to the rest server with the filetype option = csv worked fine and saved the formatted file. I don't know what caused the problem when I tried this option before. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using Budibase 2.22.0 running on my local server with MySQL database. I have some data that is processed using get requests to a python3 flask rest server that is doing pivot tables for me. This is because, to my knowledge, neither MySQL nor Budibase have pivot table functionality. The rest server is providing the pivot table data to Budibase just fine using rest GET api queries.
I decided that for some of my analysis I would like to be able to download pivoted data to a spreadsheet. For example, my rest server is returning data in JSON format to Budibase for display in a table using a call such as https://rest-server:5000/monthlysummarypivot. Now when I try to export data from Budibase using the "Export Data" action, it prevents me from doing so because no rows are selected, and row selection does not work for Rest API query tables. (It would be just dandy if there was a "select all" capability, but I digress)
My next step was to add functionality to my rest server so that if I executed a GET to my server https:/rest-server:5000/restquery?filetype=csv, the rest server executes a send_file function and sends a formatted csv file to the requestor. It works perfectly from a browser. If filetype=none or the parameter is left out completely, the GET request returns JSON exactly as Budibase wants for a table display. If filetype=csv the request, if issued from a browser, asks for a file download and does what I want.
I'm struggling to get Budibase to execute the function from a screen. I've tried putting parameters on my rest API query in the Budibase data area, but found that when the JSON request returns jsonify data it comes back under "data" as root, but when the rest server performs a send_file function to send the file back for a download, Budibase tries to interpret the data instead of allowing a download, and sees it as a structure under "value.data" as root. With these different root value structures I can't get the transformers set to work with both. I haven't figured out how to twist the parameters to make everything work, or to trigger Budibase to enable the send_file function to trigger a download. When I create a separate rest API query with the parameter hard coded with ?filetype=csv and set the transformer to "value", this query executed from a button doesn't do anything, no error, exception, or file saved.
A simple solution might to execute a navigate to the URL from Budibase using an action, but when I try that I get an error saying that it can't find the Session. I haven't explored this avenue enough to know if it is a true dead end. It seems like executing a plain URL would work the same from Budibase as from a browser tab. Keeping tabs open in the browser to export data is kind of kludgy when Budibase is doing almost everything else.
Sorry for the long-winded and muddled explanation. I'm just not getting something important. The documentation on how to pass parameters to Rest Queries seems a bit thin to me, at least from what I've found so far. Thanks if anyone can help.
Beta Was this translation helpful? Give feedback.
All reactions