0

I need to consume my company 'Target Social R3 V3' dashboard data with Good data Javascript SDK. First I'm trying to get pinterest data as start but I'm receiving error 400 Bad request. I'm newbie to good data api and following methods given in good data examples in Java script SDK.

$('#root').append('<div class="login-loader">Logging in...</div>');

gooddata.user.login(user, passwd).then(function() {
// Loged in
$('div.login-loader').remove();
$('#root').append('<div class="loading">Logged in... Loading metrics</div>');

// Do your stuff here
// ...
gooddata.md.getMetrics(projectId).then(function(dataSets) {
    $('div.loading').remove();
    $('#root').append('<div class="dataLoading">Laoding data...</div>');

    $('#root').append('<p>Total number of metrics ' + dataSets.length + '</p>');
    elements=[];
         dataSets.forEach(function(ds) {

        var dstr = JSON.stringify(ds.title);
        if(dstr.toLowerCase().indexOf("pinterest account followers") > 0)
        {
            var did = JSON.stringify(ds.identifier);
            $('#datasets').append('<li>'+did+'</li>');
            elements.push(did);
        }

    });
    $('#root').append('<p>Total number of choosen metrics '+elements.length +  ' and element '+elements[0] +'</p>');

    gooddata.execution.getData(projectId, elements).then(function(dataResult)
    {
        $('div.dataLoading').remove();
        console.log('Social Data:\n'+ JSON.stringify(dataResult));
    });

});
});

I'd appreciate if some one could explain about attributes and metrics passed here as parameters.

mmmathur
  • 103
  • 12
  • By Pinterest data you mean you are downloading a data from dataset in GoodData that contains Pinterest data? Have you specified elements for computing report (metrics and attributes)? – Jiri Tobolka Jul 25 '14 at 12:23
  • Yes you are right, but basically my goal is to extract complete dashboard data from gooddata dataset. Later I figured out that I should be rather using `getObjectDetails` method then `getData` method. with dashboard uri. But still I'm figuring out how to pass attributes and metrics. Sorry if I'm too much. – mmmathur Jul 27 '14 at 16:22

1 Answers1

0

Make sure your sample is under gooddata-js/examples/ folder (let's assume is named 'mysample') and it has index.html file in that directory. Set user and passwd variables in your script file to your real GoodData user name and password. Run grunt dev and access your sample at https://localhost:8443/mysample/index.html. It should work.

If it does not work, please provide the details (message body) of the 400 error you are getting.

Martin Matula
  • 7,969
  • 1
  • 31
  • 35
  • I'm exactly doing steps you defined above but I'm clue less how to use correct attributes and metrics to get my dashboard data. However I moved little ahead by using `getObjectDetails` method rather then using `getData` method which now returns me dashboard DOM in json. – mmmathur Jul 27 '14 at 16:28