Help - Function node error

Good afternoon

I had made a flow using an old version of N8N and now that I updated it is giving some conflict with the “Function” node

I check in the spreadsheet if a certain user ID already exists and then I look for the history of questions, and through this code I skip lines and then forward it to the HTTP Request for the chatbase

However there has been some formatting change coming out of the Function node which has resulted in an error

ERROR: The data in “Body Parameters” is not valid JSON. Set Body Content Type to “RAW/Custom” for XML or other types of payloads

NodeOperationError: The data in “Body Parameters” is not valid JSON. Set Body Content Type to “RAW/Custom” for XML or other types of payloads
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V1/HttpRequestV1.node.js:704:35)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:652:28)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:596:53

Could you please rewrite the Function Nodes with the correct formatting please? I do not understand much

Sorry if the writing is bad, I’m using google translator

Thanks in advance

Hey @PedroHenrique26,

Can you share the output from the Google Sheets node so we can take a look? I suspect the issue is with the content rather than the function nodes.

Doesn’t seem to have a pattern, I think it might be something in the message that gets in the way of encoding, but I don’t know what it is

I went to test it and it started working normally, however in the last request the error was repeated again

This was the last request that occurred correctly:

This is the most recent run, with error

image

Output from the Sheets node before going to the function

Here is the sheets with the data:

Here is the output of the Function-join1 node

it’s as if something in the history disturbs the formatting, some word, some spacing, some item, that interferes with the analysis in n8n, I can’t say

can, help-me? please

Hey @PedroHenrique26,

Can you share the JSON output for a failed request from the sheets node? Ideally this would need to be the text so that we can test it.

Good night, how are you?

I realized that the problem occurs when there is a line break in the text that will be sent by the HTTP REQUEST, is there any way to solve this?

The sheets node searches for the user’s interaction history with the chatbase, if the bot has previously responded with a line break, the http request does not work, I did the test manually editing and removing this line break and it happened normally. Is there any way to resolve this?

1 Like

I managed to solve it using a function that replaces text breaks with space, chatgpt created it, thanks a lot

2 Likes

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