diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index f87e5b7416..5fae7b4e8f 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -214,7 +214,7 @@ module RestModule { if (error) { throw "Invalid JSON for request body" } - input.body = object + input.body = string input.headers["Content-Type"] = "application/json" break } diff --git a/packages/server/src/integrations/tests/rest.spec.js b/packages/server/src/integrations/tests/rest.spec.js index 6c1d989124..d2413b4af1 100644 --- a/packages/server/src/integrations/tests/rest.spec.js +++ b/packages/server/src/integrations/tests/rest.spec.js @@ -14,6 +14,11 @@ const fetch = require("node-fetch") const RestIntegration = require("../rest") const { AuthType } = require("../rest") +const HEADERS = { + "Accept": "application/json", + "Content-Type": "application/json" +} + class TestConfiguration { constructor(config = {}) { this.integration = new RestIntegration.integration(config) @@ -35,9 +40,7 @@ describe("REST Integration", () => { const query = { path: "api", queryString: "test=1", - headers: { - Accept: "application/json", - }, + headers: HEADERS, bodyType: "json", requestBody: JSON.stringify({ name: "test", @@ -47,9 +50,7 @@ describe("REST Integration", () => { expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { method: "POST", body: '{"name":"test"}', - headers: { - Accept: "application/json", - }, + headers: HEADERS, }) }) @@ -86,9 +87,7 @@ describe("REST Integration", () => { expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { method: "PUT", body: '{"name":"test"}', - headers: { - Accept: "application/json", - }, + headers: HEADERS, }) }) @@ -107,9 +106,7 @@ describe("REST Integration", () => { const response = await config.integration.delete(query) expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { method: "DELETE", - headers: { - Accept: "application/json", - }, + headers: HEADERS, body: '{"name":"test"}', }) })