From dd06b405ebc862d4280863425bbea8111731fd7f Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 29 Jul 2021 16:47:45 -0700 Subject: [PATCH] fix 400 error in download csv --- .../reporting_api_client/reporting_api_client.ts | 14 ++++++++++---- .../public/panel_actions/get_csv_panel_action.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/reporting/public/lib/reporting_api_client/reporting_api_client.ts b/x-pack/plugins/reporting/public/lib/reporting_api_client/reporting_api_client.ts index 6c62c560b095d..5c618ba8261fa 100644 --- a/x-pack/plugins/reporting/public/lib/reporting_api_client/reporting_api_client.ts +++ b/x-pack/plugins/reporting/public/lib/reporting_api_client/reporting_api_client.ts @@ -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; + export interface DiagnoseResponse { help: string[]; success: boolean; @@ -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>( - baseParams: T - ): BaseParams { + public getDecoratedJobParams(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. diff --git a/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx b/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx index 943a543184b62..8b6e258c06535 100644 --- a/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx +++ b/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx @@ -120,7 +120,7 @@ export class ReportingCsvPanelAction implements ActionDefinition searchSource, columns, title: savedSearch.title, - objectType: 'downloadCsv', + objectType: 'downloadCsv', // FIXME: added for typescript, but immediate download job does not need objectType }); this.isDownloading = true;