HTTP Request Node - JSON w/ Expressions - Not Valid JSON Error

Describe the problem/error/question

I am using expressions in a JSON Body in the HTTP Request Node. When I click into the Expression it appears to resolve as expected. However, when I send the payload to the it clearly shows the expression is not transmitting the resolved payload but rather [object Object]. When I send the payload to the intended API endpoint, it results in a JSON Not Valid error. I have read through other posts on this topic but I am unclear as to how to get around this issue.

What is the error message (if any)?

When I send the payload to the intended API endpoint, it results in a JSON Not Valid error.

Please share your workflow

Share the output returned by the last node

Here is what the payload looks like from

{ “data”:[{
“id” : “5751937000006284011”,
“Ordered_Items”: [ [object Object],[object Object] ]}]}

Here is the expected output:

{ “data”:[{
“id” : “5751937000006284011”,
“Ordered_Items”: [ {“Product_Name”: {“id”: “5751937000001603864”}, “Quantity”: 1, “Description”: “OS80, BLACK”},{“Product_Name”: {“id”: “5751937000001603851”}, “Quantity”: 1, “Description”: “Nano, 8 ohm Version w/o Transformer, BLACK”} ]}]}

Information on your n8n setup

  • **n8n version: 1.34.2 **
  • **Database (default: SQLite): SQLite **
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): Not sure **
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker-Compose **
  • **Operating system: Linux Ubuntu 20.04.6 **

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I have updated my original post with the info. I was getting a 403 error when pasting my workflow using </> so I just pasted it raw to get around the error.

@chadgriff1 , please share your workflow to see the actual setup of your HTTP Request node and input data you are trying to utilize in the body of the request. For that, you have to copy the wokflow and paste it in between the pair of triple backticks ``` (each ``` has to be on its own line).

Is there a way around a 403 Error when pasting the workflow. I attempted to paste it within the ‘</>’ area and received a 403 error each time. I pasted it outside of the ‘</>’ area to get past it but it was removed from my post

The 403 error typically means unauthorized access or forbidden action. I’m not sure why it happens to you. Perhaps you are trying to paste something else rather than a workflow? If you just type a plain text in between ```, do you get the same error?

@ihortom I tried to paste my entire workflow but got the 403 error. I was able to paste a partial workflow that hopefully will shed some light.

That is good enough. Try using the following expression instead

      "id" : "$('Split In Batches').item.json.zohoSoId",
      "Ordered_Items": $

I assume $ is an array.

@ihortom Thanks for your help. Yes, $ is an Array. I was able to get past the JSON not Valid error by the error using the following:

“id” : “$(‘Split In Batches’).item.json.zohoSoId”,
“Ordered_Items”: $json[“data”].toJsonString()

The .toJsonString() method allowed it to resolve to the expected Json output vs. [object Object].

1 Like

That actually contradict the output you showed as the expected one as instead of an array you get string representation of an array (array vs string). That is, instead of "Ordered_Items": [...] you get "Ordered_Items": "[...]".

@ihortom Apologies…I really thought what I listed initially was what I needed to satisfy the Zoho CRM end point I am trying to hit. What you suggested was really similar to what I already had in place. I could see in the HTTP Request Node the output would resolve to [object Object] in the Expression preview (i.e. without clicking into the Expression builder). When I added the .toJsonString() method I could see in the preview it would resolve as I needed it to. When I tested using the proper end point, it worked! FYI…I am building a workflow to update Sales Orders within Zoho CRM to align with any changes made in my inventory management system. The endpoint I am using to update the Sales Order subform is

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