Error make Expression JSON Object

Hi,

I am having problems generating the Expression to send in the header on the http request node method post json / raw active my attempts

Expression:
{{JSON.parse (JSON.stringify (’{“Cookie”: “JSESSIONID =’ + $ json [” jsessionid “] + '”}’))}}

Result with node return:
{“Cookie”: “JSESSIONID = kH8siXLILnO2jUkI-aKIk-8IB7O_LEIEfDRFUOeU”}

Error presented, and I’m doing the parse:

Below I work inserting manual in place of … but I need to send the value received from a node …

Expression:
{{JSON.parse (’{“Cookie”: “JSESSIONID = …”}’)}}

{{JSON.parse (’{“Cookie”: “JSESSIONID = kH8siXLILnO2jUkI-aKIk-8IB7O_LEIEfDRFUOeU”}’)}}

Result that works:
[Object: {“Cookie”: “JSESSIONID = …”}]

[Object: {“Cookie”: “JSESSIONID = kH8siXLILnO2jUkI-aKIk-8IB7O_LEIEfDRFUOeU”}]

But I need receive … from another node.

You should be able to set the expression:

{{ {"Cookie":$json.jsessionid} }}

Here an example workflow:

{
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "jsessionid",
              "value": "asdf"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        732,
        384
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://example.com",
        "responseFormat": "string",
        "jsonParameters": true,
        "options": {},
        "headerParametersJson": "={{ {\"Cookie\":$json.jsessionid} }}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        932,
        384
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like