Skip to content

Commit

Permalink
fix 400 error in download csv
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Jul 29, 2021
1 parent 47329a1 commit dd06b40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ import {
import { add } from '../../notifier/job_completion_notifications';
import { Job } from '../job';

/*
* For convenience, apps do not have to provide the browserTimezone and Kibana version.
* Those fields are added in this client as part of the service.
* TODO: export a type like this to other plugins: https://github.com/elastic/kibana/issues/107085
*/
type AppParams = Omit<BaseParams, 'browserTimezone' | 'version'>;

export interface DiagnoseResponse {
help: string[];
success: boolean;
Expand Down Expand Up @@ -160,13 +167,12 @@ export class ReportingAPIClient implements IReportingAPI {
return new Job(resp.job);
}

public async createImmediateReport(params: BaseParams) {
public async createImmediateReport(baseParams: BaseParams) {
const { objectType: _objectType, ...params } = baseParams; // objectType is not needed for immediate download api
return this.http.post(`${API_GENERATE_IMMEDIATE}`, { body: JSON.stringify(params) });
}

public getDecoratedJobParams<T extends Omit<BaseParams, 'browserTimezone' | 'version'>>(
baseParams: T
): BaseParams {
public getDecoratedJobParams<T extends AppParams>(baseParams: T): BaseParams {
// If the TZ is set to the default "Browser", it will not be useful for
// server-side export. We need to derive the timezone and pass it as a param
// to the export API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
searchSource,
columns,
title: savedSearch.title,
objectType: 'downloadCsv',
objectType: 'downloadCsv', // FIXME: added for typescript, but immediate download job does not need objectType
});

this.isDownloading = true;
Expand Down

0 comments on commit dd06b40

Please sign in to comment.