mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(HTTP Request Node): Bug - node requires string instead of json
This commit is contained in:
parent
e275306c64
commit
8f49f494ae
|
@ -1109,19 +1109,23 @@ export class HttpRequestV3 implements INodeType {
|
|||
);
|
||||
} else if (specifyBody === 'json') {
|
||||
// body is specified using JSON
|
||||
try {
|
||||
JSON.parse(jsonBodyParameter);
|
||||
} catch (_) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'JSON parameter need to be an valid JSON',
|
||||
{
|
||||
runIndex: itemIndex,
|
||||
},
|
||||
);
|
||||
}
|
||||
if (typeof jsonBodyParameter !== 'object' && jsonBodyParameter !== null) {
|
||||
try {
|
||||
JSON.parse(jsonBodyParameter);
|
||||
} catch (_) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'JSON parameter need to be an valid JSON',
|
||||
{
|
||||
runIndex: itemIndex,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
requestOptions.body = jsonParse(jsonBodyParameter);
|
||||
requestOptions.body = jsonParse(jsonBodyParameter);
|
||||
} else {
|
||||
requestOptions.body = jsonBodyParameter;
|
||||
}
|
||||
} else if (specifyBody === 'string') {
|
||||
//form urlencoded
|
||||
requestOptions.body = Object.fromEntries(new URLSearchParams(body));
|
||||
|
|
Loading…
Reference in a new issue