HTTP Request Getting an error in n8n Node

Hi there,

I have tried to do a POST request using HTTP Request Node. When I try to do that I am getting an error like in the below.

But When I try that body parameter in the POSTMAN, It is working fine.

{ “Order”: [{ “Username”:“amila1329112206”, “OrderID”:“N376”, “OrderType”:“Quote”, “Email":"[email protected]”, “BillFirstName”:“tt”, “BillLastName”:“tt”, “BillCompany”:“”, “BillStreet1”:“151 Melbourne Road”, “BillStreet2”:“”, “BillCity”:“Rippleside”, “BillState”:“VIC”, “BillPostCode”:“3215”, “BillContactPhone”:“(070) 155-6276”, “BillCountry”:“AU”, “ShipFirstName”:“tt”, “ShipLastName”:“tt”, “ShipCompany”:“”, “ShipStreet1”:“151 Melbourne Road”, “ShipStreet2”:“”, “ShipCity”:“Rippleside”, “ShipState”:“VIC”, “ShipPostCode”:“3215”, “ShipContactPhone”:“(070) 155-6276”, “ShipCountry”:“AU”, “CustomerRef6”:“:::36:::5.07::::::576791::1::4.88:::64MLH904::1::0.19:::”, “OrderStatus”:“Quote”, “OrderApproval”:“False”, “PaymentMethod”:“”, “TaxInclusive”:“True”, “TaxFreeShipping”:“False”, “ShippingMethod”:“Standard Shipping”, “ShippingCost”:“0.00”, “ShippingDiscount”:“0.00”, “SignatureRequired”:“True”, “CurrencyCode”:“AUD”, “SalesChannel”:“Website”, “OrderLine”:[{“SKU”: “576791”, “ItemDescription”: " Festool Beech Tenon 8mm / 10mm Starter SystainerSet for DF 700 (576791)", “Quantity”: “1”, “Price”: “4.88”, “WarehouseName”: “Location #1”, “TaxFree”: “False”},{“SKU”: “64MLH904”, “ItemDescription”: " PERFECT FINISH DRYING SYSTEM ", “Quantity”: “1”, “Price”: “0.19”, “WarehouseName”: “Location #1”, “TaxFree”: “False”}] }]}

This is my body parameter.

Do you have any idea why this is not working on HTTP Request but its working on Postman?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n version: 1.22.4
**Database - SQLite n8n EXECUTIONS_PROCESS
setting - Own Running
n8n via - Docker
Operating system: Windows

hello @AmilaDeshan

Please, don’t use the raw content type for JSON. Use the JSON type. Example:
image

Hello @barn4k

Thank you for the update. But when I use that one, I am getting an error ERROR: JSON parameter need to be an valid JSON

Please check my below input JSON and OUTPUT of it,

Input JSON
{
“Order”: [
{
“Username”: “{{ $json.Username_new }}”,
“OrderID”: “{{ $json.orderID }}”,
“OrderType”: “Quote”,
“Email”: “{{ $json.email_address }}”,
“BillFirstName”: “{{ $json.bill_first_name }}”,
“BillLastName”: “{{ $json.bill_last_name }}”,
“BillCompany”: “{{ $json.companyName}}”,
“BillStreet1”: “{{ $json.billing_street}}”,
“BillStreet2”: “”,
“BillCity”: “{{ $json.billing_city }}”,
“BillState”: “{{ $json.billing_state }}”,
“BillPostCode”: “{{ $json.billing_zip }}”,
“BillContactPhone”: “{{ $json.phone_number}}”,
“BillCountry”: “{{ $json.billing_country ===‘AU’ ? ‘Australia’ :‘$json.billing_country’ }}”,
“ShipFirstName”: “{{ $json.bill_first_name }}”,
“ShipLastName”: “{{ $json.bill_last_name }}”,
“ShipCompany”: “{{ $json.companyName }}”,
“ShipStreet1”: “{{ $json.shipping_street }}”,
“ShipStreet2”: “”,
“ShipCity”: “{{ $json.shipping_city }}”,
“ShipState”: “{{ $json.shipping_state }}”,
“ShipPostCode”: “{{ $json.shipping_zip }}”,
“ShipContactPhone”: “{{ $json.phone_number }}”,
“ShipCountry”: “{{ $json.shipping_country ===‘AU’ ? ‘Australia’ : ‘$json.shipping_country’ }}”,
“CustomerRef6”: “{{ $json.q117_cusref6 }}”,
“OrderStatus”: “Quote”,
“OrderApproval”: “False”,
“PaymentMethod”: “”,
“TaxInclusive”: “True”,
“TaxFreeShipping”: “False”,
“ShippingMethod”: “Standard Shipping”,
“ShippingCost”: “0.00”,
“ShippingDiscount”: “0.00”,
“SignatureRequired”: “True”,
“CurrencyCode”: “AUD”,
“SalesChannel”: “Website”,
“OrderLine”: [
{{ $json.OrderLine }}
]
}
]
}

Result of the above input

{
“Order”: [
{
“Username”: “8mctmhmtoalm”,
“OrderID”: “kwucpbtt1818”,
“OrderType”: “Quote”,
“Email”: “[email protected]”,
“BillFirstName”: “tt”,
“BillLastName”: “tt”,
“BillCompany”: “”,
“BillStreet1”: “151 Melbourne Road”,
“BillStreet2”: “”,
“BillCity”: “Rippleside”,
“BillState”: “VIC”,
“BillPostCode”: “3215”,
“BillContactPhone”: “(070) 155-6276”,
“BillCountry”: “Australia”,
“ShipFirstName”: “tt”,
“ShipLastName”: “tt”,
“ShipCompany”: “”,
“ShipStreet1”: “151 Melbourne Road”,
“ShipStreet2”: “”,
“ShipCity”: “Rippleside”,
“ShipState”: “VIC”,
“ShipPostCode”: “3215”,
“ShipContactPhone”: “(070) 155-6276”,
“ShipCountry”: “Australia”,
“CustomerRef6”: “:::36:::5.07::::::576791::1::4.88:::64MLH904::1::0.19:::”,
“OrderStatus”: “Quote”,
“OrderApproval”: “False”,
“PaymentMethod”: “”,
“TaxInclusive”: “True”,
“TaxFreeShipping”: “False”,
“ShippingMethod”: “Standard Shipping”,
“ShippingCost”: “0.00”,
“ShippingDiscount”: “0.00”,
“SignatureRequired”: “True”,
“CurrencyCode”: “AUD”,
“SalesChannel”: “Website”,
“OrderLine”: [
{“SKU”: “576791”, “ItemDescription”: " Festool Beech Tenon 8mm / 10mm Starter SystainerSet for DF 700 (576791)", “Quantity”: “1”, “Price”: “4.88”, “WarehouseName”: “”, “TaxFree”: “False”},{“SKU”: “64MLH904”, “ItemDescription”: " PERFECT FINISH DRYING SYSTEM ", “Quantity”: “1”, “Price”: “0.19”, “WarehouseName”: “”, “TaxFree”: “False”}
]
}
]
}

When I execute the node, I am getting ERROR: JSON parameter need to be an valid JSON

This error,

At first glance, it looks good, but I don’t like the part with

"OrderLine": [
{{ $json.OrderLine }}
]

if OrderLine is an array of objects (as in your output example), it should be set as:

"OrderLine": {{ $json.OrderLine }}

OrderLine is requesting a parameter like below.

“OrderLine”: [
{
“SKU”: “576791”,
“ItemDescription”: " Festool Beech Tenon 8mm / 10mm Starter SystainerSet for DF 700 (576791)",
“Quantity”: “1”,
“Price”: “4.88”,
“WarehouseName”: “”,
“TaxFree”: “False”
},
{
“SKU”: “64MLH904”,
“ItemDescription”: " PERFECT FINISH DRYING SYSTEM ",
“Quantity”: “1”,
“Price”: “0.19”,
“WarehouseName”: “”,
“TaxFree”: “False”
}
]

$json.OrderLine value is coming like below.

{
“SKU”: “576791”,
“ItemDescription”: " Festool Beech Tenon 8mm / 10mm Starter SystainerSet for DF 700 (576791)",
“Quantity”: “1”,
“Price”: “4.88”,
“WarehouseName”: “”,
“TaxFree”: “False”
},
{
“SKU”: “64MLH904”,
“ItemDescription”: " PERFECT FINISH DRYING SYSTEM ",
“Quantity”: “1”,
“Price”: “0.19”,
“WarehouseName”: “”,
“TaxFree”: “False”
}

I need to add that $json.OrderLine value inside [ ], but when I did that, I am getting that JSON Error

No, you shouldn’t place the $json.OrderLine inside square brackets []. Because it’s already having them (if the $json.OrderLine is not a text). You can open the dev console (f12) and see in the console tab what the node sends when you are running the HTTP Node.
image

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.