Using Public DSS API in a WebApp

vdwow
Level 1
Using Public DSS API in a WebApp

Hello,

I'm building a very simple web app on DSS to fetch data from a dataset. The app is basically the standard fetching app provided by Dataiku :

function clearMessage() {
    displayMessage('');
}

function displayFailure() {
    displayMessage('The dataset cannot be retrieved. Please check the dataset name or the API Key\'s permissions in the "Settings" tab of the webapp.', 'error-message');
}

function displayDataFrame(dataFrame) {
    let columnsNames = dataFrame.getColumnNames();
    let line = '------------------------------';
    let text = selectedDataset.name + '\n'
        + line + '\n'
        + dataFrame.getNbRows() + ' Rows\n'
        + columnsNames.length + ' Columns\n'
        + '\n' + line + '\n'
        + 'Columns names: \n';
    columnsNames.forEach(function(columnName) {
        text += columnName + ', ';
    });
    displayMessage(text);
}

fetchButton.addEventListener('click', function(event) {
    clearMessage();
    selectedDataset.name = document.getElementById('dataset-to-fetch').value;
    dataiku.fetch(selectedDataset.name, function(dataFrame) {
        selectedDataset.dataFrame = dataFrame;
        displayDataFrame(dataFrame);
    }, function() {
        displayFailure();
    });
    return false;
});

 

I've authorized the app to access the particular dataset (read / write) but i keep getting the following message (default message in default DSS web app) :

"The dataset cannot be retrieved. Please check the dataset name or the API Key's permissions in the "Settings" tab of the webapp."

 

Is there something else to do after authorizing the app to access the dataset ?

 

Thanks in advance.

0 Kudos
1 Reply
SarinaS
Dataiker

Hi @vdwow ,

Thank you for providing your detailed steps.  

In order to access the dataset from this base webapp, you should only need to allow access under the webapp Settings > Security > configure settings: 

Screen Shot 2021-03-30 at 12.16.43 PM.png

It sounds like you already did this. 

I would suggest just double-checking these settings and that the dataset exists exactly as you are entering it.  Then as a next step, it would probably be helpful to see the exact call that the webapp is making and the corresponding error.  You can do this by accessing the developer tools in Chrome (More Tools > Developer Tools) and then attempting you "Fetch" call again. 

You might notice that there is a typo in the dataset name or that the error actually originates from something else.  For example, this is what I see if I try and fetch a dataset name that doesn't exist:

Screen Shot 2021-03-30 at 12.26.27 PM.png

If that doesn't help with identifying what might be wrong, can you please attach a screenshot of your dataset settings and the full POST call (as shown above)?

Thanks,
Sarina 

0 Kudos