@@ -184,6 +184,21 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
184184 }
185185 } ) ( ) ;
186186
187+ const formattedRequestBody : Record < string , any > = ( ( ) => {
188+ if ( requestBody instanceof FormData || requestBody instanceof URLSearchParams ) {
189+ return Object . fromEntries ( requestBody ) ;
190+ } else if ( typeof requestBody === 'string' ) {
191+ try {
192+ return JSON . parse ( requestBody ) ;
193+ } catch {
194+ return { content : requestBody } ;
195+ }
196+ } else if ( typeof requestBody === 'object' && requestBody !== null ) {
197+ return requestBody ;
198+ }
199+ return { } ;
200+ } ) ( ) ;
201+
187202 try {
188203 const { formatResponse, rawResponse } = await ( async ( ) => {
189204 const systemPluginCb = await getSystemPluginCb ( ) ;
@@ -225,7 +240,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
225240 [ DispatchNodeResponseKeyEnum . nodeResponse ] : {
226241 totalPoints : 0 ,
227242 params : Object . keys ( params ) . length > 0 ? params : undefined ,
228- body : Object . keys ( requestBody ) . length > 0 ? requestBody : undefined ,
243+ body : Object . keys ( formattedRequestBody ) . length > 0 ? formattedRequestBody : undefined ,
229244 headers : Object . keys ( headers ) . length > 0 ? headers : undefined ,
230245 httpResult : rawResponse
231246 } ,
@@ -241,7 +256,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
241256 [ NodeOutputKeyEnum . error ] : formatHttpError ( error ) ,
242257 [ DispatchNodeResponseKeyEnum . nodeResponse ] : {
243258 params : Object . keys ( params ) . length > 0 ? params : undefined ,
244- body : Object . keys ( requestBody ) . length > 0 ? requestBody : undefined ,
259+ body : Object . keys ( formattedRequestBody ) . length > 0 ? formattedRequestBody : undefined ,
245260 headers : Object . keys ( headers ) . length > 0 ? headers : undefined ,
246261 httpResult : { error : formatHttpError ( error ) }
247262 } ,
0 commit comments