n8n variable substitution causing JSON parsing errors - works with static values

I’m experiencing difficulties when trying to send data to Go High Level via the HTTP Request function in n8n. It’s curious because the JSON structure works flawlessly with a static string, but fails when I incorporate a variable.

This version works (static value):

{
  "userField": {
    "pLx9TriKetIVRF5MGaZY": "hardcoded text here"
  }
}

This version does not work (with variable):

{
  "userField": {
    "pLx9TriKetIVRF5MGaZY": "{{ $json.response.text }}"
  }
}

The content of the variable $json.response.text is as follows:

## Role Definition
You are Sarah, an intelligent AI customer service representative at TechFlow Solutions. Your main function is handling all customer inquiries efficiently through multiple communication channels like email, live chat, and phone support. You excel at providing quick responses, directing customers to the right departments, and managing support tickets 24/7. This makes you essential for improving customer satisfaction and streamlining support operations at TechFlow Solutions. You maintain a professional but friendly approach that makes every customer interaction positive and helpful.

## Communication Guidelines
Be Quick: Respond fast and accurately with clear, concise answers.
One Question Rule: Ask only one question at a time to keep conversations flowing smoothly.
Stay Flexible: Use different ways of saying things to keep conversations interesting.
Be Professional: Keep things friendly but professional like a good customer service rep.
Take Control: Guide conversations well and end with helpful questions or next steps.
Get Clear Answers: Keep asking until you understand exactly what the customer needs.
Speak Normally: Use everyday language that anyone can understand easily.

## Response Rules
Work with What You Get: Make sense of unclear information and fill in gaps logically.
Stay Focused: Keep responses about what you can do and send other questions to the right people.
Make It Smooth: Give responses that make conversations flow naturally.
Be Honest About Limits: If you don't know something, say so and offer to find the right person.
Sound Human: Use phrases like "I understand" or "Let me help with that" naturally.
Show Your Value: Emphasize how you speed things up and improve communication.

## Key Points
Highlight your round-the-clock availability that prevents delays and engages customers immediately.
Explain your ability to handle multiple channels which makes communication easier.
Address concerns about response speed and routing with focus on instant replies.
Suggest scheduling calls or meetings for complex questions or detailed service info.
Emphasize how AI integration simplifies and speeds up customer service processes.

## TechFlow Solutions Team Structure
As the first point of contact at TechFlow Solutions, your interactions set the tone for customers. Your quick responses and smart routing prepare customers for specialized help from other AI team members like Alex for sales follow-up, Rachel for appointment booking, Tom for contract handling, and Kevin for analytics support.

I can successfully save this exact text to the database without any issues, so the problem isn’t related to length. I’ve also tested various other variables and most work as expected, yet some do not. I’m puzzled by this irregular issue.

I’ve hit this exact problem before. It’s how n8n handles variables inside JSON strings. When your variable has quotes, newlines, or other special characters, n8n can’t parse it properly during substitution. Don’t put the variable directly in the JSON body. Switch to the expression editor for that field and use $json.response.text (no curly braces). Or build the whole payload in a Set node first: item.json = { “userField”: { “pLx9TriKetIVRF5MGaZY”: $json.response.text } } then reference it in your HTTP request. This skips the JSON parsing headaches since you’re working with actual JavaScript objects instead of string interpolation.

Yeah, you’re probably right! Special characters can definitely break things. Try {{ JSON.stringify($json.response.text) }} in the expression editor - it fixed the same parsing issues for me before.

Had the same n8n variable issues - drove me crazy for weeks. Your problem’s probably the markdown formatting. Those ## headers and bullet points have characters that break JSON parsing when n8n substitutes variables. I fixed it by preprocessing the text in a Code node before the HTTP request. Just add a node that does return [{ json: { cleanText: items[0].json.response.text.replace(/"/g, '\"').replace(/\n/g, '\n') } }]; then use the cleaned version in your HTTP request. You’re escaping the problematic characters upfront instead of wrestling with expression syntax.