HTTP Request JSON Body issue - JSON bdy parameter hierarchy depth limit?

I am trying to post a raw json to the new mongodb atlas rest API using n8n cloud.

The JSON body looks like

 { "dataSource": "Cluster", 
"database": "test", 
"collection": "stuff", 
"document": {"GroupId": "Foo", "quantity": "123"}
}

The error message is
ERROR: The data in “Body Parameters” is no valid JSON. Set Body Content Type to “RAW/Custom” for XML or other types of payloads

NodeOperationError: The data in "Body Parameters" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest.node.js:741:35)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:442:47

It seems as though the body parameters have a depth limit?

I have tried using the parameters option but thos wraps the document item in quotes when testing output using pipedream.io.

Many thanks

Pete

Information on your n8n setup

  • n8n Cloud:
  • n/a
  • Running n8n via n8n.cloud

Hey @blahblahblah, welcome to the community :tada:

I’m sorry to hear you’re having trouble here. The payload looks good to me and I could use the example you have provided just fine in the HTTP Request node.

I did however notice you are using an expression as per your screenshot. So I am wondering if you might have a situation where the expression is producing valid JSON (like in your example) for the first item (which would be the one previewed on the node details view) but might return invalid JSON for subsequent items.

Would you be able to share the exact expression you are using in your Body Parameters field as well as the input data your HTTP Request node receives (which can of course be redacted, I simply want to understand the data structure you are working with)?