Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/sim/tools/http/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
return allHeaders
},

body: (params: RequestParams) => {
body: ((params: RequestParams) => {
if (params.formData) {
const formData = new FormData()
Object.entries(params.formData).forEach(([key, value]) => {
Expand All @@ -90,19 +90,19 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
) {
// Convert JSON object to URL-encoded string
const urlencoded = new URLSearchParams()
Object.entries(params.body).forEach(([key, value]) => {
Object.entries(params.body as Record<string, unknown>).forEach(([key, value]) => {
if (value !== undefined && value !== null) {
urlencoded.append(key, String(value))
}
})
return urlencoded.toString()
}

return params.body
return params.body as Record<string, any>
}

return undefined
},
}) as (params: RequestParams) => Record<string, any> | string | FormData | undefined,
},

transformResponse: async (response: Response) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/http/webhook_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const webhookRequestTool: ToolConfig<WebhookRequestParams, RequestRespons
return { ...webhookHeaders, ...userHeaders }
},

body: (params: WebhookRequestParams) => params.body,
body: (params: WebhookRequestParams) => params.body as Record<string, any>,
},

transformResponse: async (response: Response) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface ToolConfig<P = any, R = any> {
url: string | ((params: P) => string)
method: HttpMethod | ((params: P) => HttpMethod)
headers: (params: P) => Record<string, string>
body?: (params: P) => Record<string, any> | string
body?: (params: P) => Record<string, any> | string | FormData | undefined
}

// Post-processing (optional) - allows additional processing after the initial request
Expand Down