# HTTP POST special characters

**URL:** <https://discourse.nodered.org/t/http-post-special-characters/86232>\
**Category:** General\
**Tags:** http-request\
**Created:** [7 March 2024 11:29 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232 "2024-03-07T11:29:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlos-conde](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/carlos-conde/32/89028_2.png) [@carlos-conde](https://discourse.nodered.org/u/carlos-conde)\
**Post date:** [7 March 2024 11:29 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/1 "2024-03-07T11:29:19Z")

</div>

Hello everyone.

I'm trying to make a POST request with an "http request" node, where the body is a JSON containing text with accents.

If I make a POST request with the body (without accents):

```json
{
     "field_0": "GARCIA PEREZ, IVAN",
     "__metadata": {
       "type": "SP.Data.EmployeesListItem"
     }
}

```

The request is accepted, returns 201.

If you make a POST request with the body (with tildes):

```json
{
     "field_0": "GARCÍA PÉREZ, IVÁN",
     "__metadata": {
       "type": "SP.Data.EmployeesListItem"
     }
}

```

The request is unsuccessful, returning 400: Invalid JSON. An unexpected end of input was found in the JSON content. Not all object and array scopes were closed.

How can I resolve this error so that I can send string values with accents in the body of the POST request?

  

_Admin edit: surrounded code snippets with backticks_

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 March 2024 12:01 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/2 "2024-03-07T12:01:09Z")

</div>

@carlos-conde Welcome to the forum!

1. what version of NR and node.js are you running? (you can find this in the startup log)
2. what platform are you running NR on?

I did a copy of the data you say is causing the error and sent it thru a `json` node and it had no problem with it.

Please create a small flow demonstrating your issue and then export it and attach it to a reply.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 March 2024 12:06 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/3 "2024-03-07T12:06:45Z")

</div>

Try adding the header  
`Content-Type` `application/json; Charset=UTF-8`

Question: Are you sending a JS object in the payload OR making the JSON string yourself?

---

<div class="post-metadata">

**Author:** ![carlos-conde](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/carlos-conde/32/89028_2.png) [@carlos-conde](https://discourse.nodered.org/u/carlos-conde)\
**Post date:** [11 March 2024 11:25 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/4 "2024-03-11T11:25:16Z")

</div>

Hi, thank you for response

I have tried adding those headers, but it did not solve the problem.  
I have tried sending a JSON object and also a JSON Object parsed to String, it has not solved the problem either.

But I have managed to make the POST with special characters using the request library in a function node.

---

<div class="post-metadata">

**Author:** ![carlos-conde](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/carlos-conde/32/89028_2.png) [@carlos-conde](https://discourse.nodered.org/u/carlos-conde)\
**Post date:** [11 March 2024 11:27 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/5 "2024-03-11T11:27:54Z")

</div>

Hi, thank you for response

I'm going to edit my post.

But I solved using request library

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 March 2024 11:33 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/6 "2024-03-11T11:33:47Z")

</div>

That is not good. Could you share both a non working flow (using HTTP node) and your working flow please? I would like to investigate this further.

---

<div class="post-metadata">

**Author:** ![carlos-conde](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/carlos-conde/32/89028_2.png) [@carlos-conde](https://discourse.nodered.org/u/carlos-conde)\
**Post date:** [11 March 2024 11:37 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/7 "2024-03-11T11:37:10Z")

</div>

I can't edit my post ☹

Anyway.

version node-red: 1.3.5  
plataform: Ubuntu Server 22.04.4 LTS

example:

```auto
   [
    {
        "id": "b5f8496f.14d4c8",
        "type": "inject",
        "z": "e41869bb.09b5a8",
        "name": "ADD",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "20",
        "topic": "add",
        "payload": "",
        "payloadType": "date",
        "x": 250,
        "y": 200,
        "wires": [
            [
                "2ac302f7.1b52ee"
            ]
        ]
    },
    {
        "id": "2ac302f7.1b52ee",
        "type": "function",
        "z": "e41869bb.09b5a8",
        "name": "config req",
        "func": "try{\n const body = {\n \"Title\": \"01001989\",\n \"field_0\": \"C@RLOS KÖNDE KANTÉ\"\n }\n const len = JSON.stringify(body).length;\n \n msg.payload = body;\n // msg.payload = JSON.stringify(body);\n \n msg.headers = {\n 'Authorization': 'Barear + accestoken',\n 'Content-Type': \"application/json;\",\n 'Content-Length': len,\n 'X-RequestDigest': \"{form_digest_value}\"\n }\n \n msg.url = \"https:/....sharepoint.com/.../web/lists/getByTitle('listName')/items\";\n \n node.status({ fill: \"green\", text: \"done\" });\n return msg;\n}catch(err){\n node.status({ fill: \"red\", text: \"error\" });\n node.error(err);\n throw err;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 200,
        "wires": [
            [
                "7af78bcc.1e27f4"
            ]
        ]
    },
    {
        "id": "7af78bcc.1e27f4",
        "type": "http request",
        "z": "e41869bb.09b5a8",
        "name": "add",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 550,
        "y": 200,
        "wires": [
            []
        ]
    }
] 

```

Solved:

```auto
   [
    {
        "id": "8be1e4a3.4be038",
        "type": "function",
        "z": "8e958c14.3560d",
        "name": "add",
        "func": "try{\n const request = global.get('request');\n \n const url = 'https://.....sharepoint.com/..../_api/web/lists/getByTitle(\\'ListName\\')/items';\n const data = {\n \"Title\": \"01001989\",\n \"field_0\": \"C@RLOS KÖNDE KANTÉ\"\n }\n const options = {\n 'method': 'POST',\n 'url': url,\n 'headers': {\n 'Authorization': 'Bearer + access_token',\n 'Accept': 'application/json;odata=verbose',\n 'X-RequestDigest': '{form_digest_value}',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(data)\n };\n \n request(options, function (error, response) {\n if (response.statusCode === 201) {\n node.status({ fill: \"green\", text: response.statusCode });\n return response;\n }\n if (response.statusCode !== 201) {\n node.status({ fill: \"yellow\", text: response.statusCode });\n return response;\n }\n if (error) {\n node.status({ fill: \"red\", text: \"error\" });\n node.error(error);\n return error;\n }\n });\n}catch(err){\n node.status({ fill: \"red\", text: \"error\" });\n node.error(err);\n throw err;\n}",
        "outputs": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 530,
        "y": 300,
        "wires": [],
        "icon": "node-red/white-globe.svg"
    }
]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 March 2024 11:40 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/8 "2024-03-11T11:40:05Z")

</div>

> [@carlos-conde](#):
>
> version node-red: 1.3.5

That is an old release of NR. The current release is 3.1.6

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 March 2024 12:05 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/9 "2024-03-11T12:05:27Z")

</div>

> [@carlos-conde](#):
>
> version node-red: 1.3.5

Are you certain that is correct? That version is 3 years old (ancient in terms of Node-RED)

Also what version of NodeJS are you using?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 June 2024 12:06 UTC](https://discourse.nodered.org/t/http-post-special-characters/86232/10 "2024-06-09T12:06:05Z")

</div>

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