Problem in HTTP Request node: "JSON parameter needs to be valid JSON"

Hi everyone,

I'm encountering a persistent issue with the HTTP Request node in my n8n workflow when trying to upsert a metafield in Shopify via their REST API.

How can I safely send a JSON string inside a JSON object in the jsonBody without n8n interpreting it incorrectly or throwing JSON parameter needs to be valid JSON?

Thanks in advance for your help! — Alexandre

Describe the problem/error/question

Problem in HTTP Request node: “JSON parameter needs to be valid JSON”.

:magnifying_glass_tilted_left: Context:

  • I’m using this node to send a POST or PUT request to the Shopify REST API:

    POST /admin/api/2025-07/orders/{order_id}/metafields.json
    PUT  /admin/api/2025-07/metafields/{metafield_id}.json
    
    
  • I pass a metafield value that is a JSON stringified object.

  • My jsonBody looks like this (expression in value):

{
  "metafield": {
    "namespace": "custom",
    "key": "sav_content",
    "type": "json",
    "value": "{{ $json.thread_data }}"
  }
}

  • thread_data is prepared using JSON.stringify({...}) in a previous Set node.

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

no output

Information on your n8n setup

    1. n8n version: 1.105.3 (EC2)
    2. Database: SQLite (default)
    3. n8n EXECUTIONS_PROCESS setting: main
    4. Running via: Docker (on EC2 AWS instance)
    5. Operating System: Linux (Amazon Linux 2)

Hey @ASJ_BBK hope all is good. Welcome to the community.

First, try to use the following jsonBody:

{
  "metafield": {
    "namespace": "custom",
    "key": "sav_content",
    "type": "json",
    "value": "{{ $json.thread_data.toJsonString() }}"
  }
}

If that doesn’t work, please share the content of the $json.thread_data.

Thanks for your help @jabbson. I’ve just tried and still have the same issue “JSON parameter needs to be valid JSON”.

Ok, then please share your workflow and either pin the data in the node preceding http request node or provide the value of {{ $json.thread_data }}

here is the workflow with pinned data


and $json.tread_data contains the following data:

={"sav_thread":{"created_at":"2025-08-14T16:44:02.461Z","total_messages":1,"messages":[{"id":1755189842,"type":"customer_question","date":"2025-08-14T09:05:06.000Z","subject":"Autre question","content":"Bonjour, J'ai bien reçu le tipi, mais je n'ai pas reçu 16 morceaux de bois comme indiqué sur votre site. J'en ai eu seulement 12, ce qui fait que le tipi est complètement affaissé. De plus l'un des morceaux s'est cassé quand je l'ai enfoncé dans la partie blanche en plastique. Je l'ai recollé avec du scotch mais je préfèrerai qu'il soit remplacé. Pourriez vous me renvoyer 5 morceaux de bois ainsi que 4 attaches blanches qui seront manquantes pour fixer ce qui me manquait ? Cordialement,","marketplace":"Nature & Découvertes"}]}}

The problem in your attached workflow is likely leading double quote:

Thanks, my bad. Unfortunately, even with this edit, it does not end up the right way. Now, here is the new error :

**Your request is invalid or could not be processed by the service**

422 - “{\“errors\”:{\“value\”:[\“is invalid JSON: unexpected character: ‘={\\\“sav_thread\\\”:{\\\“created_at\\\”:\\\"20’.\”]}}”

Here is the new output result:

{
  "metafield": {
    "namespace": "custom",
    "key": "sav_content",
    "type": "json",
    "value": ""={\"sav_thread\":{\"created_at\":\"2025-08-14T16:44:02.461Z\",\"total_messages\":1,\"messages\":[{\"id\":1755189842,\"type\":\"customer_question\",\"date\":\"2025-08-14T09:05:06.000Z\",\"subject\":\"Autre question\",\"content\":\"Bonjour, J'ai bien reçu le tipi, mais je n'ai pas reçu 16 morceaux de bois comme indiqué sur votre site. J'en ai eu seulement 12, ce qui fait que le tipi est complètement affaissé. De plus l'un des morceaux s'est cassé quand je l'ai enfoncé dans la partie blanche en plastique. Je l'ai recollé avec du scotch mais je préfèrerai qu'il soit remplacé. Pourriez vous me renvoyer 5 morceaux de bois ainsi que 4 attaches blanches qui seront manquantes pour fixer ce qui me manquait ? Cordialement,\",\"marketplace\":\"Nature & Découvertes\"}]}}""
  }
}

is = sign in the beginning expected by the service?

Also, I didn’t mean to add the quotation mark in the beginning, I mean removing one at the end.

1 Like

Hi @jabbson, the “=” was on the previous step. I remove it, just as the quotation mark at the beginning and at the end. Thanks a lot for your follow-up.

1 Like

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