I’m facing an issue with an HTTP node in my n8n workflow where it throws a “JSON not set correctly” error in a Set node. The API response structure is inconsistent. Sometimes the response comes as output.content.text, other times as output.content.text.result.
I’ve created different JSON paths in the Set node to handle these variations, and it works in some executions but fails in others, even with the same setup.
I’m trying to understand what I’m doing wrong and how to properly handle inconsistent response formats in n8n without breaking the workflow. Any guidance would be appreciated.
Hi @Samar_Abbas , please can you share your workflow in a code block. The issue is not really with your set node and ideally you want to force the resulting json structure to ALWAYS be consistent and the same so that it is predictable.
My initial question is what is the different between the AI Agent and the Message a model nodes. Why do you have two of these?
My suggestion would be to use an AI Agent node with the Structured Output sub node so you can force the json structure to always be the same. This way you can avoid having to cater for n-th number of results which is very messy and highly unmaintainable.
Here’s an example:
@Wouter_Nigrini Thank you for your response.
Can you guide me on how to share my workflow in a code block?
Yes sure, select all the nodes in your workflow and copy. Then in the reply here click the code button and paste inside. It’ll then share the workflow