HTTP Request POST to GPTs Assistants

Describe the problem/error/question

I’m trying to access my GPT Assistant using an HTTP Request node in n8n

JSON parameter needs to be valid JSON - I’ve already tried lots of recommendations from different AIs, but nothing worked

{
assistant_id: “asst_EbQr4qLCgZ9X7zzt1igjJVD0”,
thread: {
messages: [
{
role: “user”,
content: $json.chatInput
}
]
}
}

What is the error message (if any)?

JSON parameter needs to be valid JSON

NodeOperationError: JSON parameter needs to be valid JSON at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_afd197edb2c1f848eae21a96a97fab23/node_modules/n8n-nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts:430:15) at WorkflowExecute.executeNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1265:31) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1446:22) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1847:38 at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2461:11

Please share your 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:

In your POST request, put $json.chatInput inside double brackets and quotation marks.

“{{ $json.chatInput }}”

Also in your GET request there is a false expression. {{thread_id}} will return undefined in this case. If the last node will output a field called “thread_id” then this is the correct expression:

{{ $json.thread_id }}

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