From d6a2bd77788c318a9f74247a52a1b6da05779b4b Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Wed, 6 Sep 2023 07:38:39 -0600 Subject: [PATCH] [Actions] Adjust axios payload for APIs that do not want `data` sent (#165756) --- x-pack/plugins/actions/server/lib/axios_utils.test.ts | 3 --- x-pack/plugins/actions/server/lib/axios_utils.ts | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugins/actions/server/lib/axios_utils.test.ts b/x-pack/plugins/actions/server/lib/axios_utils.test.ts index 1f94e610f60bf..7423042e68228 100644 --- a/x-pack/plugins/actions/server/lib/axios_utils.test.ts +++ b/x-pack/plugins/actions/server/lib/axios_utils.test.ts @@ -66,7 +66,6 @@ describe('request', () => { expect(axiosMock).toHaveBeenCalledWith('/test', { method: 'get', - data: {}, httpAgent: undefined, httpsAgent: expect.any(HttpsAgent), proxy: false, @@ -100,7 +99,6 @@ describe('request', () => { expect(axiosMock).toHaveBeenCalledWith(TestUrl, { method: 'get', - data: {}, httpAgent, httpsAgent, proxy: false, @@ -132,7 +130,6 @@ describe('request', () => { expect(axiosMock).toHaveBeenCalledWith('https://testProxy', { method: 'get', - data: {}, httpAgent: undefined, httpsAgent: expect.any(HttpsAgent), proxy: false, diff --git a/x-pack/plugins/actions/server/lib/axios_utils.ts b/x-pack/plugins/actions/server/lib/axios_utils.ts index 181893db15f0c..163eac3eada2b 100644 --- a/x-pack/plugins/actions/server/lib/axios_utils.ts +++ b/x-pack/plugins/actions/server/lib/axios_utils.ts @@ -51,7 +51,7 @@ export const request = async ({ ...config, method, headers, - data: data ?? {}, + ...(data ? { data } : {}), // use httpAgent and httpsAgent and set axios proxy: false, to be able to handle fail on invalid certs httpAgent, httpsAgent,