Skip to content

The open alternative to Salesforce, designed for AI.

fix: set `content-type` header for isMethodWithBody (#13839)

neo773a9156666e517
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useTestHttpRequest.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useTestHttpRequest.test.ts
index bdb6de1a4d6..299ee81ab1f 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useTestHttpRequest.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useTestHttpRequest.test.ts
@@ -116,7 +116,6 @@ describe('useTestHttpRequest', () => {
expect.objectContaining({
method: 'GET',
headers: expect.objectContaining({
- 'Content-Type': 'application/json',
Authorization: 'Bearer test-token-123',
}),
}),
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useHttpRequestForm.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useHttpRequestForm.ts
index 6b53b9cfa86..10ed32aa5b9 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useHttpRequestForm.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useHttpRequestForm.ts
@@ -54,6 +54,16 @@ export const useHttpRequestForm = ({
newFormData = { ...newFormData, body: undefined };
}
+ if (field === 'method' && isMethodWithBody(value as string)) {
+ newFormData = {
+ ...newFormData,
+ headers: {
+ ...newFormData.headers,
+ 'content-type': 'application/json',
+ },
+ };
+ }
+
setFormData(newFormData);
saveAction(newFormData);
};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useTestHttpRequest.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useTestHttpRequest.ts
index 79ea621cea8..62493af4481 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useTestHttpRequest.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/useTestHttpRequest.ts
@@ -58,10 +58,7 @@ export const useTestHttpRequest = (actionId: string) => {
const requestOptions: RequestInit = {
method: httpRequestFormData.method,
- headers: {
- 'Content-Type': 'application/json',
- ...(substitutedHeaders as Record<string, string>),
- },
+ headers: substitutedHeaders as Record<string, string>,
};
if (['POST', 'PUT', 'PATCH'].includes(httpRequestFormData.method)) {