HTTP Request Error message

I have a valid JSON body going to a server via the HTTP Request node. i checked the HTTP output with json linter and postman.

n8n throws a “JSON parameter need to be an valid JSON” error. Postman gives me the legit error, 417 expectation failed.
I know because the request body has data that fails validation at the server, not because the JSON payload is invalid. Is there any way to get a more accurate response from n8n?
I’ve turned on “Always Output Data”, and “Include Response Headers and Status”. No difference in the error message.

I’m on the most recent hosted version of n8n and HTTP Request node version 4.1 (Latest)

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:

Hey @Mike_Z,

Can you share the workflow you are using? This normally means that you are using an expression and the field is not a JSON type and is just a string which is why we are returning the validation error.

If you can share a workflow that reproduces it and any data that is needed we can take a look.

1 Like

Hi @Jon
I modified the HTTP Request to go to RequestBin

Thanks for taking the time to look

Hey @Mike_Z,

There is no data pinned to the input so I can’t test it but I can see what the issue is and it is what I was expecting. So the JSON field expects the data to be a JSON object but it currently contains a string that looks like JSON.

Try setting the body to something like

{{ 
{
	"items": $json["lines"],
	"taxes": [{
		"tax_amount": $('Rename Keys').item.json["data"]["total_tax"], 
		"charge_type": "Actual",
		"cost_center": "Main - SHM",
		"description": "Local Sales Tax",
		"account_head": "2310 - NYS Sales Tax - SHM"
	}, {
		"tax_amount": $('Rename Keys').item.json["data"]["total_shipping_price_set"]["shop_money"]["amount"],
		"charge_type": "Actual",
		"cost_center": "Main - SHM",
		"description": "Amount Collected from Customer for Shipping (pos)",
		"account_head": "4115 - Shipping Sales - SHM"
	}],
	"total": $('Input').item.json["body"]["total_price"],
    "net_total": $('Input').item.json["body"]["total_price"],
    "base_net_total": $('Input').item.json["body"]["total_price"],
    "base_total": $('Input').item.json["body"]["total_price"],
	"is_pos": 1,
	"company": "Safe Haven Music",
	"currency": "USD",
	"customer": "$('Edit Fields').item.json["customer_first_name"] + " " +$('Edit Fields').item.json["customer_last_name"]",
	"debit_to": "1310 - Acct Receivable - SHM",
	"due_date": $('Input').item.json["body"]["created_at"].substring(0,10),
	"payments": [{
		"type": "Bank",
		"amount": $('Input').item.json["body"]["total_price"]-$('Input').item.json["body"]["total_outstanding"],
		"account": "1260 - Shopify Payments - SHM",
		"default": 0,
		"mode_of_payment": "shopify_payments"
	}],
    "grand_total": $('Input').item.json["body"]["total_price"],
    "base_grand_total": $('Input').item.json["body"]["total_price"],
    "docstatus": 0,
	"pos_profile": $('Edit Fields').item.json["pos_profile"],
	"posting_date": $('Input').item.json["body"]["created_at"].substring(0,10),
	"posting_time": $('Input').item.json["body"]["created_at"].substring(11,19),
	"update_stock": 1,
	"naming_series":  $('Edit Fields').item.json["naming_series"],
	"customer_group": $('Edit Fields').item.json["customer_group"],
	"conversion_rate": 1,
	"discount_amount": $('Input').item.json["body"]["total_discounts"],
	"set_posting_time": 1,
	"selling_price_list": "Standard Selling",
	"plc_conversion_rate": 1,
	"price_list_currency": "USD",
	"market_place_order_id": $('Input').item.json["body"]["name"]+1
}
}}