# Help - Function node error

**URL:** <https://community.n8n.io/t/help-function-node-error/27871>\
**Category:** Questions\
**Tags:** function\
**Created:** [July 6, 2023, 7:54pm UTC](https://community.n8n.io/t/help-function-node-error/27871 "2023-07-06T19:54:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 6, 2023, 7:54pm UTC](https://community.n8n.io/t/help-function-node-error/27871/1 "2023-07-06T19:54:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [July 7, 2023, 9:48am UTC](https://community.n8n.io/t/help-function-node-error/27871/3 "2023-07-07T09:48:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 7, 2023, 8:07pm UTC](https://community.n8n.io/t/help-function-node-error/27871/4 "2023-07-07T20:07:17Z")

</div>

![image](https://europe1.discourse-cdn.com/n8n/original/3X/1/7/1775c2b0a27f9b6fee154cfb1f58216a89b0d058.png)

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:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/2/7/27592ae87b2418d6d47839132d8dd07ce1caa1c9.png)

This is the most recent run, with error

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/8/1/81468efe053ff27e17125356970722e290ab1c76.png)

---

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 7, 2023, 8:07pm UTC](https://community.n8n.io/t/help-function-node-error/27871/5 "2023-07-07T20:07:52Z")

</div>

![image](https://europe1.discourse-cdn.com/n8n/original/3X/7/4/744f2d01c35b2a841d43a8216477260623751641.png)

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/5/3/5360476912389442cdb6631ec513ea989b9a4485.png)

Output from the Sheets node before going to the function

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/0/00d2dfca62bb4d29e9a7d5918cda56b19cdc12f3.png)

Here is the sheets with the data:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/2/a/2ab606697cfd40e8c33901d44686f20855b2bebb.png)

Here is the output of the Function-join1 node

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/8/5/852255a7b165fe3d50658d85b69ce5c9c41f4d21.png)

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

---

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 9, 2023, 1:28pm UTC](https://community.n8n.io/t/help-function-node-error/27871/6 "2023-07-09T13:28:38Z")

</div>

can, help-me? please

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [July 10, 2023, 7:02am UTC](https://community.n8n.io/t/help-function-node-error/27871/7 "2023-07-10T07:02:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 13, 2023, 11:36pm UTC](https://community.n8n.io/t/help-function-node-error/27871/8 "2023-07-13T23:36:13Z")

</div>

> [@Jon](#):
>
> JSON output for a failed request from the sheets node

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?

---

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 13, 2023, 11:42pm UTC](https://community.n8n.io/t/help-function-node-error/27871/9 "2023-07-13T23:42:13Z")

</div>

![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/8/086913c548ac73ecc0e6dea925b98a1d48e3e249.png)

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?

---

<div class="post-metadata">

**Author:** ![PedroHenrique26](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pedrohenrique26/32/26435_2.png) [@PedroHenrique26](https://community.n8n.io/u/PedroHenrique26)\
**Post date:** [July 14, 2023, 12:03am UTC](https://community.n8n.io/t/help-function-node-error/27871/10 "2023-07-14T00:03:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [July 21, 2023, 12:03am UTC](https://community.n8n.io/t/help-function-node-error/27871/11 "2023-07-21T00:03:28Z")

</div>

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