Error-JSON parameter needs to be valid JSON [item 0]

I’m getting an error at HTTP request while running workflow. I try to resolve this issue by using the topic similar this issue, but i’m unable to fix it.

Error message is “JSON parameter needs to be valid JSON [item 0]”
please find the screenshot for reference.

Here is my JSON code:
{
“template”: “9XtfsD0C3Tb2vbvfc84d”,
“variables”: {
“title”: “{{ $(‘Google Sheets’).item.json.Subject }}”,
“voiceModel”: “elevenlabs”,
“voice.ConnectionID”: “my-elevenlabs-connection”,
“voiceID”: “21m00Tcm4TlvDq8ikWAM”,
“imageModel”: “flux-pro”,
“introImagePrompt”: “{{ $(‘Intro & Outro’).item.json.output.introImagePrompt }}”,
“introVoiceoverText”: “{{ $(‘Intro & Outro’).item.json.output.introVoiceoverText }}”,
“outroImagePrompt”: “{{ $(‘Intro & Outro’).item.json.output.outroImagePrompt }}”,
“outroVoiceoverText”: “{{ $(‘Intro & Outro’).item.json.output.outroVoiceoverText }}”,
“ranking”: [
{
“voiceoverText”: “{{ $json.output[0].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[0].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[0].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[1].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[1].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[1].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[2].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[2].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[2].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[3].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[3].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[3].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[4].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[4].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[4].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[5].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[5].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[5].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[6].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[6].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[6].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[7].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[7].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[7].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[8].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[8].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[8].lowerThirdText }}”
},
{
“voiceoverText”: “{{ $json.output[9].voiceoverText }}”,
“imagePrompt”: “{{ $json.output[9].imagePrompt }}”,
“lowerThirdText”: “{{ $json.output[9].lowerThirdText }}”
}
]
}
}

JSON Code Result:
{
“template”: “9XtfsD0C3Tb2vbvfc84d”,
“variables”: {
“title”: “Top Ten Cities”,
“voiceModel”: “elevenlabs”,
“voice.ConnectionID”: “my-elevenlabs-connection”,
“voiceID”: “21m00Tcm4TlvDq8ikWAM”,
“imageModel”: “flux-pro”,
“introImagePrompt”: “A panoramic view of iconic skyline silhouettes from around the world, featuring famous landmarks like the Eiffel Tower, Statue of Liberty, and Tokyo Tower, set against a vibrant sunset sky.”,
“introVoiceoverText”: “Welcome to our countdown of the Top 10 Cities in the world! From bustling metropolises to charming historical towns, these cities offer a unique blend of culture, architecture, and life. Get ready to embark on a journey to explore these amazing urban landscapes!”,
“outroImagePrompt”: “A collage of photographs depicting lively urban scenes, from street markets to skylines, with a creative graphic ‘Thanks for Watching!’ at the center.”,
“outroVoiceoverText”: “We’ve just traveled through some of the most captivating cities across the globe. Which city captured your heart the most? Let us know in the comments below. Thank you for joining our urban adventure!”,
“ranking”: [
{
“voiceoverText”: “Kicking off our countdown at number 10 is Barcelona, Spain. Known for its stunning architecture by Antoni Gaudí, like the Sagrada Família and Park Güell, this vibrant city offers a perfect blend of history, culture, and beautiful beaches.”,
“imagePrompt”: “A panoramic view of Barcelona with the Sagrada Família in the foreground, surrounded by the city’s vibrant landscape and beaches.”,
“lowerThirdText”: “Barcelona, Spain”
},
{
“voiceoverText”: “At number 9, we have Tokyo, Japan. A bustling metropolis that blends ultramodern with traditional, Tokyo is famous for its skyscrapers, tech influence, and rich cultural heritage including ancient temples.”,
“imagePrompt”: “The Tokyo skyline featuring the iconic Tokyo Tower and Mount Fuji in the background, with a mix of modern and traditional architecture.”,
“lowerThirdText”: “Tokyo, Japan”
},
{
“voiceoverText”: “Coming in at number 8 is Istanbul, Turkey. Straddling two continents, Europe and Asia, Istanbul is known for its historic sites like the Hagia Sophia and the Blue Mosque, making it a unique cultural hub.”,
“imagePrompt”: “A view of Istanbul’s skyline showcasing the Bosphorus Strait and iconic landmarks like the Hagia Sophia and the Blue Mosque.”,
“lowerThirdText”: “Istanbul, Turkey”
},
{
“voiceoverText”: “Number 7 on our list is New York City, USA. Known as “The City That Never Sleeps,” New York is renowned for its iconic landmarks such as Times Square, Central Park, and the Statue of Liberty.”,
“imagePrompt”: “A vibrant cityscape of New York City featuring Times Square, Central Park, and the Statue of Liberty in the background.”,
“lowerThirdText”: “New York City, USA”
},
{
“voiceoverText”: “Coming in at number 6 is Paris, France. Often called the “City of Lights,” Paris is synonymous with romance, fashion, and art, home to the Eiffel Tower, Louvre Museum, and charming cafés.”,
“imagePrompt”: “A romantic view of Paris with the Eiffel Tower lit up at night, surrounded by charming street cafés and the Seine River.”,
“lowerThirdText”: “Paris, France”
},
{
“voiceoverText”: “At number 5 is Sydney, Australia. Known for its stunning harbor, iconic Opera House, and beautiful beaches, Sydney offers a vibrant arts scene and a laid-back coastal lifestyle.”,
“imagePrompt”: “Sydney’s iconic skyline featuring the Opera House and Sydney Harbour Bridge with a sunny beach in the foreground.”,
“lowerThirdText”: “Sydney, Australia”
},
{
“voiceoverText”: “Ranked at number 4 is Rome, Italy. The Eternal City is famous for its ancient ruins like the Colosseum, the Vatican City, and its rich Italian cuisine, attracting history buffs and food lovers alike.”,
“imagePrompt”: “A historical view of Rome featuring the Colosseum, Vatican City, and charming streets lined with Italian cafes.”,
“lowerThirdText”: “Rome, Italy”
},
{
“voiceoverText”: “Number 3 belongs to Rio de Janeiro, Brazil. Known for its breathtaking landscapes, Carnival festival, and iconic Christ the Redeemer statue, Rio is a city full of vibrant culture and natural beauty.”,
“imagePrompt”: “The iconic Christ the Redeemer statue overlooking Rio de Janeiro with Sugarloaf Mountain and vibrant cityscapes.”,
“lowerThirdText”: “Rio de Janeiro, Brazil”
},
{
“voiceoverText”: “Coming in at number 2 is London, England. With its rich history, world-class museums, and iconic landmarks such as Big Ben and Buckingham Palace, London remains a major cultural and financial hub.”,
“imagePrompt”: “A classic view of London’s skyline with Big Ben, the London Eye, and Buckingham Palace surrounded by bustling streets.”,
“lowerThirdText”: “London, England”
},
{
“voiceoverText”: “And finally, taking the top spot at number 1 is Dubai, UAE. Known for its record-breaking architecture, luxury shopping, and vibrant nightlife, Dubai is a city that never fails to impress.”,
“imagePrompt”: “A modern skyline of Dubai featuring the towering Burj Khalifa and luxury shopping malls amid a glowing cityscape.”,
“lowerThirdText”: “Dubai, UAE”
}
]
}
}

Information on your n8n setup

  • n8n version:
    1.85.4 (Self Hosted)
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via n8n cloud
  • Operating system:

Hi @yarram_kartheek_redd

The error you’re seeing — “JSON parameter needs to be valid JSON [item 0]” — usually happens when the expression isn’t returning a proper JSON format.

I’d suggest wrapping your expressions in JSON.stringify() to ensure it’s valid JSON.

For example:

{{ JSON.stringify( $json.output[0].voiceoverText ) }}

Give that a try and see if it resolves the issue!

Hi , Thanks for your reply.

I made changes to the code. Still facing same error.

JSON CODE:

{
“template”: “9XtfsD0C3Tb2vbvfc84d”,
“variables”: {
“title”: “{{ JSON.stringify( $(‘Google Sheets’).item.json.Subject ) }}”,
“voiceModel”: “elevenlabs”,
“voice.ConnectionID”: “my-elevenlabs-connection”,
“voiceID”: “21m00Tcm4TlvDq8ikWAM”,
“imageModel”: “flux-pro”,
“introImagePrompt”: “{{ JSON.stringify( $(‘Intro & Outro’).item.json.output.introImagePrompt ) }}”,
“introVoiceoverText”: “{{ JSON.stringify( $(‘Intro & Outro’).item.json.output.introVoiceoverText ) }}”,
“outroImagePrompt”: “{{ JSON.stringify( $(‘Intro & Outro’).item.json.output.outroImagePrompt ) }}”,
“outroVoiceoverText”: “{{ JSON.stringify( $(‘Intro & Outro’).item.json.output.outroVoiceoverText ) }}”,
“ranking”: [
{
“voiceoverText”: “{{ JSON.stringify( $json.output[0].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[0].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[0].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[1].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[1].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[1].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[2].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[2].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[2].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[3].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[3].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[3].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[4].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[4].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[4].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[5].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[5].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[5].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[6].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[6].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[6].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[7].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[7].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[7].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[8].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[8].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[8].lowerThirdText ) }}”
},
{
“voiceoverText”: “{{ JSON.stringify( $json.output[9].voiceoverText ) }}”,
“imagePrompt”: “{{ JSON.stringify( $json.output[9].imagePrompt ) }}”,
“lowerThirdText”: “{{ JSON.stringify( $json.output[9].lowerThirdText ) }}”
}
]
}
}

Hi, please remove the extra quotation marks because JSON.stringify already returns a quoted string. For example, instead of writing:

"voiceoverText": "{{ JSON.stringify( $json.output[0].voiceoverText ) }}",

you should write:

"voiceoverText": {{ JSON.stringify( $json.output[0].voiceoverText ) }},

Thank you so much, its working. :slight_smile:

2 Likes

You’re welcome!:pray:t2:

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