API call not JSON safe

I use this workflow template - OpenAI GPT-3: Company Enrichment from website content | n8n workflow template

This workflow works amazing!

I did change OpenAI node to ML studio HTTP call. I do run ML Studio locally. In other workflows ML studio works fine. In this particular it doesn’t due to ERROR: JSON parameter need to be an valid JSON

Is there any solution to convert any content to JSON safe?

For example in another workflow for me worked this code:

const inputDescription = items[0].json.description;
const outputDescription = inputDescription.replace(/\n/g, “”).replace(/ +(?= )/g,‘’);

return [{ json: { description: outputDescription } }];

Share the output returned by the last node

Information on your n8n setup

  • n8n version: latest
  • Database (default: SQLite): postgress
  • n8n EXECUTIONS_PROCESS setting - default
  • Running n8n via (Docker):
  • Operating system: win 11

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:

Hey @Ivars_Pavlovich,

Without having a copy of the output from the other nodes it is hard to say but I have ran your json through jsonlint.com and it doesn’t appear to be valid even if I swap out the expressions with normal text so I would start there.

Hey @Jon , thanks for your response.

Below, I have simplified the workflow. Does it work for you?

Hey @Ivars_Pavlovich,

Looking at the JSON it is still invalid, It is failing on the first content role, In your content you will need to make sure you escape the " characters this could be done in the code node.

Thanks for the answer