ERROR: JSON parameter need to be an valid JSON...and JSON.stringify does not seem to work

Hello !

I already encountered the “ERROR: JSON parameter need to be an valid JSON” issue and was able to circumvent it thanks to the JSON.stringify tip.

However, I am working on a new workflow and it does not seem to help me this time. I try putting it on every field and just the string fields but I have the same message.

I have each time verified the JSON format from an external validator to be sure I don’t have another issue.

Please share your workflow

Here is the problematic node :

The JSON Body I am using is the following :

{"name": {{ JSON.stringify($json.products[0].name) }},"kind": {{ JSON.stringify($json.products[0].kind) }},"categoryId": {{ $json.products[0].category.id }},"brand": {"name": {{ JSON.stringify($json.products[0].brand) }}},"longDescription": {{ JSON.stringify($json.products[0].longDescription) }},"status": {{ JSON.stringify($json.products[0].status) }},"tags":[{{ $json.products[0].tags[0].id }}],"position": {{ $json.products[0].position}},"images": [{"id":{{ $json.products[0].variants[0].images[0].id }}}],     "variants": [{  "id":{{ $json.products[0].variants[0].id }},"basePrice": {{ $('Google Sheets1').item.json.Prix }}, "quantity": {{ $('Google Sheets1').item.json.Stock }},"position": {{ $json.products[0].variants[0].position }},"isDefault": {{ $json.products[0].variants[0].isDefault }},"images": [{"id":{{ $json.products[0].variants[0].images[0].id }}}]}]}

The editor shows that this is the body that should be sent with the data I have added through the workflow :

{"name": "Peluche Pain Au Chocolat Jellycat - Douceur et Style pour Votre Boulangerie!","kind": "simple","categoryId": 1362,"brand": {"name": "Jellycat"},"longDescription": "<h4>Peluche Pain Au Chocolat Jellycat - Douceur et Style pour Votre Boulangerie!</h4><br>Vous voulez donner une touche de douceur et de style à votre boulangerie? C'est maintenant possible avec la peluche Pain au Chocolat Jellycat! Cette peluche moelleuse et super douce est le compagnon parfait pour tous les fans de viennoiseries.<br><br><h4>Un design adorable</h4><br><br>La peluche Pain au Chocolat Jellycat est faite pour vous faire fondre. Avec son design adorable, elle est l'accessoire parfait pour ajouter une touche de douceur et de charme à votre boulangerie. Cette peluche est également idéale pour les enfants qui aiment jouer et câliner.<br><br><h4>Une qualité incomparable</h4><br>Fabriquée à partir de matériaux de la plus haute qualité, cette peluche est résistante et durable. Elle est douce et agréable au toucher, ce qui en fait un compagnon de jeu parfait pour les enfants. N'hésitez pas à la laver régulièrement pour maintenir sa douceur et son état comme neuf!<br><br><h4>Les avantages du Peluche Pain Au Chocolat Jellycat :</h4><br><br><ul>  <li>Design adorable pour ajouter une touche de douceur et de charme à votre boulangerie</li>  <li>Fabriqué à partir de matériaux de haute qualité pour une résistance et une durabilité incroyable</li>  <li>Doux et agréable au toucher, parfait pour les enfants qui aiment câliner et jouer</li></ul><br><br>Offrez à votre boulangerie une touche de douceur avec la peluche Pain au Chocolat Jellycat!","status": "online","tags":[3],"position": 13,"images": [{"id":544989}],     "variants": [{  "id":301957,"basePrice": 10.99, "quantity": 30,"position": 1,"isDefault": true,"images": [{"id":544989}]}]}

Information on your n8n setup

  • **n8n version:Cloud
  • Running n8n via Desktop App:
  • Operating system: Windows

Thanks for your advices and help on this one ^^

Hello,

Sorry, I realized the issue was coming from another item that was sent afterwards.

It can be closed

2 Likes

Hi @Romain_Mangattale Glad you’re able to solve the issue. :tada: