HTTP Request Node returns HTML instead of Audio Binary after Looping Gemini JSON Array

Describe the problem/error/question

What is the problem?

I am trying to build an automated video content creation workflow. My Basic LLM Chain node (Google Gemini) generates a video script formatted as a JSON Array. I parse this array using the Edit Fields (Set) node with {{ JSON.parse($json.text) }} and then pass it to a Loop Over Items node to process each scene sequentially.

Inside the loop, I have an HTTP Request node meant to send each scene text to a free TTS API (StreamElements) and download the audio as a binary file. However, instead of getting an .mp3 play button/binary file, the HTTP Request node downloads the website’s HTML source code (data.html, text/html), or gives an incorrect host / domain value / Invalid URL error when I try to reference the dynamic data.


My Workflow Structure

  1. Chat Trigger :right_arrow: Starts the flow.

  2. Basic LLM Chain (Gemini) :right_arrow: Generates JSON Array script string.

  3. Edit Fields (Set) :right_arrow: Uses {{ JSON.parse($json.text) }} to create an actionable array called sahneler.

  4. Loop Over Items :right_arrow: Splits the array into individual items (Batch Size: 1).

  5. HTTP Request (Ses Ăśretici) :right_arrow: Set to GET method, Response Format is set to File. Loop output points back to the loop node.

The Error & Current State

When I try to use the dynamic text inside the URL string like this:
https://streamelements.com{{ encodeURIComponent($json.sahneler.metin) }}

The node preview shows undefined or throws an Invalid URL error. It seems the HTTP Request node loses track of the data structure coming out of the Loop node or cannot handle the encoding properly, resulting in downloading the base domain’s HTML instead of the audio payload.

What I need help with:

How can I correctly reference the text property of the current loop item inside the HTTP Request URL so that it dynamically passes the script paragraph and correctly triggers the .mp3 file download?

Thank you in advance!



(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Once try this URL inside the HTTP Request Node https://api.streamelements.com/kappa/v2/speech?voice=Brian&text={{ encodeURIComponent($json.metin) }}
I hope it fixes your issue

Welcome @Engin_Keser!

SE-automations nailed the URL fix. One thing worth clarifying on the expression side: in your Set node you store the parsed array into a field called sahneler. When Loop Over Items processes it, each iteration gives you one element from that array directly as $json - so if your array items look like {"metin": "some text"}, you access the text as $json.metin, not $json.sahneler.metin. The final URL should be:

https://api.streamelements.com/kappa/v2/speech?voice=Brian&text={{ encodeURIComponent($json.metin) }}

Also make sure Response Format in the HTTP Request node is set to File to get the binary .mp3 back instead of parsed JSON.

Welcome to the n8n community @Engin_Keser
You need to normalize the audio URL before the HTTP request and download it in binary mode.
Learn how to use binary data in n8n (video included) | n8n workflow template

:slightly_smiling_face: Is this fix issue