Gemini Http Request returns corrupted UTF-8 encoding for Turkish characters

Describe the problem/error/question

Hello,

Short version:

I’m experiencing intermittent character encoding issues with Gemini API where Turkish characters get corrupted to Chinese characters.

Long version:

I have an agent that performs real-time analysis of videos uploaded to specific YouTube channels. I send the video link and some instructions along with the prompt to the following endpoint (Gemini API):

https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent

It had been working without issues for a long time. However, I started getting an error like the one below with Gemini 2.5 Pro. I then switched to Gemini 3 Pro thinking it was a model-related issue, but the error persists. From what I understand, there’s a problem related to Turkish characters and UTF-8.

And the problem doesn’t happen with all requests. Some of them returns an unreadable text. I would really appreciate it if you could help.

I always update to the latest version of n8n cloud. This problem seems to be a Gemini endpoint issue but I wanted to be sure if there is any Http Request Node issues out there after the latest updates.

What is the error message (if any)?

The Prompt that I use:

**return {
contents: [
{
role: “user”,
parts: [
{
fileData: {
mimeType: “video/*”,
fileUri: $input.first().json.videoUrl
}
},
{
text: `This is a long prompt so I removed it`
}
]
}
],
generationConfig: {
responseMimeType: “text/plain”
}
};

This is what I get from Gemini (http request):

AJet鈥檌n yurt d谋艧谋 u莽u艧lar谋 i莽in g眉ncellenen bagaj prosed眉rlerini, limitlerini ve bilet segmentlerine g枚re (Basic, EcoJet, Flex, Premium) de臒i艧en bagaj haklar谋n谋 yolculara net bir 艧ekilde 枚臒retmek.\n\n**RTB:**\nK眉莽眉k 莽anta, kabin bagaj谋 ve kay谋tl谋 bagaj i莽in sunulan kesin 枚l莽眉ler (cm), a臒谋rl谋k limitleri (kg) ve bilet paketlerinin kapsam谋n谋 g枚steren detayl谋 kar艧谋la艧t谋rma tablosu.

Please share your workflow

{
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={{$json}}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1840,
        128
      ],
      "id": "18c9d131-a7e9-4ced-a68e-bad123b032e9",
      "name": "HTTP Request2",
      "retryOnFail": true,
      "waitBetweenTries": 4000,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "return {\n  contents: [\n    {\n      role: \"user\",\n      parts: [\n        {\n          fileData: {\n            mimeType: \"video/*\",\n            fileUri: $input.first().json.videoUrl\n          }\n        },\n        {\n          text: `Bir reklam ajansında çalışan kıdemli bir stratejik planl...
//This is a long prompt so I removed it//
\n`\n        }\n      ]\n    }\n  ],\n  generationConfig: {\n    responseMimeType: \"text/plain\"\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1632,
        128
      ],
      "id": "d61aa65d-823f-4795-b892-f258c28994c4",
      "name": "Code6"
    }
  ],
  "connections": {
    "HTTP Request2": {
      "main": [
        [],
        []
      ]
    },
    "Code6": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "removed the id"
  }
}

Share the output returned by the last node

Example 1: Corrupted Response
{
“candidates”: [
{
“content”: {
“parts”: [
{
“text”: “Stratejik Mesaj:\nAJet鈥檌n yurt d谋艧谋 u莽u艧lar谋 i莽in g眉ncellenen bagaj prosed眉rlerini…”
}
]
}
}
]
}
Decoded Text (corrupted):
“AJet’in yurt d谋艧谋 u莽u艧lar谋 i莽in g眉ncellenen bagaj prosed眉rlerini..”
Expected Text:
“AJet’in yurt dışı uçuşları için güncellenen bagaj prosedürlerini…”

Information on your n8n setup

  • n8n version: 1.123.5
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: mac Tahoe 26.1

Hi,

Right now, it’s not clear if n8n is rendering it like that or that’s what you got from the endpoint. Try to add this to Content-Type:
application/json; charset=utf-8

Right now, you just have “application/json”.

I would try to see if that helps.

If it still happens, try to add a response to the HTTP request node with a response format of “file” to get the raw data. You can put a js code node after it to see what the raw response is.

Khem

2 Likes

Hi,

Actually yesterday I did as you mentioned and added a charset parameters for the header and it seems that the problem is solved. But I still want to figure out where the problem is coming from; Gemini endpoint or n8n http request node.

But again, using application/json; charset=utf-8 parameter seems to be a solution for now (still checking the new executions for a corrupted char response and will update during the week if any happens).

Thanks by the way for the quick and direct solution to the problem.

That’s good to hear.

A way to tell whether it’s n8n related or not would be to make a request using Curl and see what you get. Try with just “application/json” as the content-type.

Khem

Actually I tested this on two workflows. One of them is using an AI Agent node with Gemini model attached to it. The other is just the same method I’m using; an HTTP Request node. The AI Agent node works perfect, no character issues. The Http Node breaks something. It’s something new. I believe this node is broken somehow after the last update.

1 Like

It worked for a few days without any issues, but the character encoding problem has started again now. In short, the issue wasn’t resolved with the charset=utf-8 parameter. There’s a very high chance this is a problem related to the HTTP Request node.

If anyone has knowledge about this, I’d appreciate it if you could let me know.

Hello again,

Gemini app itself just answered me with a corrupted text now. So this issue is not about n8n. This is for sure.

I just wanted to update you guys.

Have a nice day.

g.

1 Like

That is strange indeed, @yurtgoktug . Thanks for the additional information.

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