Yes, return a file from the REST handler. I’d like to return a query result in a csv formatted file as a download. I think they’ll want the json as well but not wrapped in the typical response and just the data section. However I have tried to implement per the documentation and it only returns empty JSON.
Client wants this change pretty quick; really appreciate the help.
You’ll need to send custom headers for that download anyway. Easiest do in a one-off handler method that delivers the spreadsheet and add a conditional in the current action to deliver the file if the flag is passed. There’s a downloadFile method in this “QueryToCSV” helper, should get you started (though it performs an immediate flush/abort ):
Thanks Jon, very appreciated. I think I can get started with the QueryToCSV, thanks for that. As for the handler, how would I call downloadFile(filePath)? How far off is this example where my Route points to this function below? I’m not sure what to return. Also, I don’t think QueryToCSV takes the Query object right?
function DataDownloadHandler(event, rc, prc) {
queryService = new Query();
queryService.setDatasource(“myDb”);
queryService.setSQL(myQueryString)"