How to send json string with double quotes?

Hello!
I need to send an HTTP request with JSON in a body with the following content:

const data = {
‘testing’: ‘1’,
‘lifetime’: ‘129600’,
‘items’: ‘[{“name”: “Yura”, “price”: 1}]’
};

special attention to the items field, it’s a string! this is how it should be passed, with double quotes inside.

And the question: how to make it so that it would be transmitted
‘items’: ‘[{“name”: “Yura”, “price”: 1}]’,
but not
‘items’: ‘[{\“name\”: \“Yura\”, \“price\”: 1}]’
i.e. without escaping double quotes.

Information on your n8n setup

  • n8n version: self hosted 0.196.0
  • Database you’re using (default: SQLite): mysql
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker

If it’s a JS object it should be fine, otherwise you can try {{ JSON.stringify(data) }}.

Best if you can share an example workflow with sample data though.

“HTTP request 5” sends the request with escaped quotes, but this is not allowed - the service will not accept such data
In the second request, I remove the backslashes, but then it gives an error “ERROR: JSON parameter need to be an valid JSON”

Thanks everyone, problem solved.
The problem was different

1 Like

Could you please explain the problem and fix in your case?

it was my mistake - I did not work correctly with the rest api