Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statistics export url should explicitly request CSV via query parameter #1049

Closed
hsilva-keep opened this issue Sep 1, 2017 · 1 comment
Closed
Assignees
Milestone

Comments

@hsilva-keep
Copy link
Member

ATM, we register an event handler for statistics export:

element.click(function() {
        var type = 'text/csv';
        $.ajax({
          accepts: {
            text: type
          },
          url: url,
          processData: false,
          dataType: 'text',
          success: function(data) {
            saveAs(new Blob([data], {
              type: type
            }), filename);
          }
        });
      });

But, in a scenario where the browser also adds some accepts headers, in front of our, the response might not be CSV.

E.g.

curl -u admin:PWD 'https://demo.roda-community.org/api/v1/index?returnClass=org.roda.core.data.v2.risks.IndexedRisk&&facet=currentSeverityLevel&lang=pt_PT&onlyActive=false&exportFacets=true&filename=risk-severity.csv' -H 'Accept: application/xml, text/csv, */*; q=0.01'

where it should be

curl -u admin:PWD 'https://demo.roda-community.org/api/v1/index?returnClass=org.roda.core.data.v2.risks.IndexedRisk&&facet=currentSeverityLevel&lang=pt_PT&onlyActive=false&exportFacets=true&filename=risk-severity.csv&acceptFormat=csv' -H 'Accept: application/xml, text/csv, */*; q=0.01'
@nunovieira220
Copy link
Contributor

nunovieira220 commented Sep 1, 2017

Done on b9ad289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants