Please help on fixing: JSON parameter needs to be valid JSON

Describe the problem/error/question

JSON looks fine and result was showing in the expression screen correctly, though when I tried to run it the error msg prompted “JSON parameter needs to be valid JSON”, please advice how I could fix it, I’m trying to use the Title and Contents and upload to blogger, thank you so much!

What is the error message (if any)?

JSON parameter needs to be valid JSON

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.92.2 (Self Hosted)
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Hostinger.com
  • Operating system: Windows
1 Like

You have invalid JSON syntax:

"content": = "whatever" is invalid.
It should be "content": "whatever" (no equals character in the middle)

If it still isn’t working after you fix that error, try it the way it is described in this post

1 Like

Hi @J_Tang

Edit your JSON body to:

{
  "kind": "blogger#post",
  "blog": {
    "id": "5785419579746801781"
  },
  "title": {{ JSON.stringify( $json.Contents[1].output.title ) }}, 
  "content": {{ JSON.stringify( $json.Contents[0].output ) }}
}
1 Like

Thank you so much, it works after changing to this:
“content”: {{ JSON.stringify( $json.Contents[0].output ) }}

Got to be stringify here V5!!

Thanks for the reply, it works after changing into this:
“content”: {{ JSON.stringify( $json.Contents[0].output ) }}

Hi all…I encountered the the same problem when I added a code note to remove the html blockers~~~~ The results are showing correctly inside the expression window but error occurred for JSON invalid…Please advice~~ Thanks!!

use JSON.stringify() again on $json.content so it escape characters like quotes (") and backslashes (\). which will cause issues with the json structure

Thank you all, should be like this:
{
“kind”: “blogger#post”,
“blog”: {
},
“title”: “{{ $json.data[1].output.title}}”,
“content”: {{ JSON.stringify( $json.content ) }}
}

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