diff --git a/app/client/src/transformers/RestActionTransformer.ts b/app/client/src/transformers/RestActionTransformer.ts index 4af3506e28..b9b3b28672 100644 --- a/app/client/src/transformers/RestActionTransformer.ts +++ b/app/client/src/transformers/RestActionTransformer.ts @@ -48,8 +48,8 @@ export const transformRestAction = (data: any): any => { let body: any = ""; if ( - contentType === POST_BODY_FORMAT_OPTIONS[0].value || - contentType === POST_BODY_FORMAT_OPTIONS[3].value + contentType !== POST_BODY_FORMAT_OPTIONS[1].value && + contentType !== POST_BODY_FORMAT_OPTIONS[2].value ) { action.actionConfiguration.bodyFormData = undefined; if (action.actionConfiguration.body) diff --git a/app/client/src/transformers/RestActionTransformers.test.ts b/app/client/src/transformers/RestActionTransformers.test.ts index 5a86861825..91ee9c4fc3 100644 --- a/app/client/src/transformers/RestActionTransformers.test.ts +++ b/app/client/src/transformers/RestActionTransformers.test.ts @@ -1,5 +1,6 @@ import { transformRestAction } from "transformers/RestActionTransformer"; import { PluginType, RestAction } from "entities/Action"; +import { POST_BODY_FORMAT_OPTIONS } from "constants/ApiEditorConstants"; // jest.mock("POST_"); @@ -85,7 +86,7 @@ describe("Api action transformer", () => { ...BASE_ACTION.actionConfiguration, httpMethod: "POST", headers: [{ key: "content-type", value: "application/json" }], - body: ["{ name: 'test' }", null], + body: "{ name: 'test' }", }, }; const output = { @@ -108,9 +109,9 @@ describe("Api action transformer", () => { ...BASE_ACTION.actionConfiguration, httpMethod: "POST", headers: [ - { key: "content-type", value: "application/x-www-form-urlencoded" }, + { key: "content-type", value: POST_BODY_FORMAT_OPTIONS[1].value }, ], - body: [{ name: "test" }, [{ key: "hey", value: "ho" }]], + bodyFormData: [{ key: "hey", value: "ho" }], }, }; const output = { @@ -119,9 +120,10 @@ describe("Api action transformer", () => { ...BASE_ACTION.actionConfiguration, httpMethod: "POST", headers: [ - { key: "content-type", value: "application/x-www-form-urlencoded" }, + { key: "content-type", value: POST_BODY_FORMAT_OPTIONS[1].value }, ], - body: '[{"key":"hey","value":"ho"}]', + body: "", + bodyFormData: [{ key: "hey", value: "ho" }], }, }; const result = transformRestAction(input); @@ -135,7 +137,7 @@ describe("Api action transformer", () => { ...BASE_ACTION.actionConfiguration, headers: [{ key: "content-type", value: "text/html" }], httpMethod: "POST", - body: [{ name: "test" }, [{ key: "hey", value: "ho" }], "raw body"], + body: "raw body", }, }; const output = {