Use Public DSS API in a JavaScript WebApp

florianbriand Registered Posts: 12 ✭✭✭✭

In a Dataiku WebApp, I want to put a link to "export" a dataset in CSV.

This is covered by the "dataset / get data" entrypoint in the public API ( ).

But if I just put a link `<a href="https://mydataikuinstance/public/...">` the browser ask for credentials when I click on the link.

How could I proceed ? Is it possible to handle this entrypoint with the JavaScript dataiku library, as it is possible in Python with the dataikuapi library ?


Best Answer


  • florianbriand
    florianbriand Registered Posts: 12 ✭✭✭✭

    Hi !

    Thanks for your answer ! I've used the python backend, by more or less doing the same thing as explained in the link you provided.

    from datetime import datetimeimport dataikuimport pandas as pdfrom flask import request, send_file, redirect, url_for@app.route('/<studyId>/users/export')def export_study_users(studyId):# ... Prepare the dataset according to studyId, with variables, jobs = = now.strftime("%Y%m%d_%H%M%S")filename = f'users_{studyId}_{now}.xlsx'return redirect(url_for('export_study_users_file', studyId=studyId, filename=filename))@app.route('/<studyId>/users/export/<filename>')def export_study_users_file(studyId, filename):consumers = dataiku.Dataset(`{studyId}_consumers`)response = send_file(consumers.raw_formatted_data(format="excel"),attachment_filename=filename,as_attachment=True,cache_timeout=-1,)response.headers["x-filename"] = filenameresponse.headers["x-suggested-filename"] = filenameresponse.headers["Access-Control-Expose-Headers"] = 'x-filename'return response

    But the `x-filename`headers seems blocked by the Flask configuration, so I'm not able to handle "properly" the download client-side ; I have to cheat

Setup Info
      Help me…