How to send literal '{{1}}' in JSON body without the JS conversion to to '1' in HTTP node?

Body:
I’m using the HTTP node to send a JSON body with a static placeholder {{1}} to send requests to the Whatsapp Business API. Here’s a sample:

{  
  "message": "Hello {{1}}",  
  "dynamic": "{{ $json.data.value }}"  
}  

When I set the Body to “Expression,” {{1}} becomes 1, but I need it sent as ‘{{1}}’ as the template expects variables to be defined like that. When I set it to Fixed this would work obviously but then all the other values cant be mapped any longer. Problem is also that I am generating the json structure dynamically which means I cant use the “Use Input Fields” and then only set that part to Fixed as the total number of input fields is not fixed.
Does anyone know how to solve this?

Information on your n8n setup

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

Hi @Kiremit

Try this expression to escape the braces:

{  
  "message": "Hello {{ '{' + '{' +  '1' + '}' + '}' }}",  
  "dynamic": "{{ $json.data.value }}"  
}  

If this answers your question, Kindly mark the reply as the solution :white_check_mark: so others with the same issue can find it easily :pray:t2:

3 Likes

@mohamed3nan Great answer thanks a lot!

1 Like

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