Upload File to Wordpress - Non latin characters Problem

Hello.

Latest Version of n8n with PostgreSQL.

I try to upload a file with non latin characters by using HTTP node to a Wordpress site and it throws an error.

Invalid character in header content ["content-disposition"]

When i do the same POST request via Postman with non latin characters it works.

Is there any workaround?

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:

Hi @Mulen,

I think you’re right that the non latin characters are causing the issue here. To fix this, you can try using the encodeURIComponent() function to encode your filename.

{{ encodeURIComponent("Δοκιμαστικό Κείμενο.tiff") }}

This will convert the non-Latin characters into a format that’s safe for HTTP headers which should prevent the error. Give it a try!

Here is a similar question from the past: Encode URI Component help

Try this

Hey aya. Thanks it works but the name in the media library is shown like this

image

This is not desireable :frowning:

It does not work with non-latin characters. Same problem.

Invalid character in header content ["content-disposition"]

I tried with Postman as i said and another workflow tool, Make.com and you can upload a file to media library with non-latin characters just fine. I think something with the HTTP node is happening.

try this one

attachment; filename*=UTF-8''{{encodeURIComponent("Δοκιμαστικό Κείμενο.tiff")}}

It’s not actually an issue with the HTTP node, as it acts according to the RFC and you are not allowed to use non-ASCII symbols in the Content-Disposition field

1 Like

Hey @barn4k

Just tried it but still the node throws another error.

{"code":"rest_upload_invalid_disposition","message":"\u0394\u03b5\u03bd \u03c0\u03b1\u03c1\u03ad\u03c7\u03b5\u03c4\u03b1\u03b9 \u03ad\u03b3\u03ba\u03c5\u03c1\u03b7 \u0394\u03b9\u03ac\u03b8\u03b5\u03c3\u03b7 \u03a0\u03b5\u03c1\u03b9\u03b5\u03c7\u03bf\u03bc\u03ad\u03bd\u03bf\u03c5. \u0397 \u0394\u03b9\u03ac\u03b8\u03b5\u03c3\u03b7 \u03a0\u03b5\u03c1\u03b9\u03b5\u03c7\u03bf\u03bc\u03ad\u03bd\u03bf\u03c5 \u03c7\u03c1\u03b5\u03b9\u03ac\u03b6\u03b5\u03c4\u03b1\u03b9 \u03bd\u03b1 \u03b5\u03af\u03bd\u03b1\u03b9 \u03bc\u03bf\u03c1\u03c6\u03bf\u03c0\u03bf\u03b9\u03b7\u03bc\u03ad\u03bd\u03b7 \u03c9\u03c2 \u03c3\u03c5\u03bd\u03b7\u03bc\u03bc\u03ad\u03bd\u03bf; \u03cc\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5=\"\u03b1\u03c1\u03c7\u03b5\u03af\u03bf.png\".","data":{"status":400}}

Which translates to

{
  "code": "rest_upload_invalid_disposition",
  "message": "Δεν παρέχεται έγκυρη Διάθεση Περιεχομένου. Η Διάθεση Περιεχομένου χρειάζεται να είναι μορφοποιημένη ως συννημένο; όνομα αρχείου=\"αρχείο.png\".",
  "data": {
    "status": 400
  }
}

In English

"No valid Content-Disposition provided. The Content-Disposition needs to be formatted as an attachment; filename="file.png"."

This is the flow (url is not real)

Well, I don’t see the original error Invalid character in header content ["content-disposition"] is from the Axios library, so maybe guys could change the HTTP Node behavior

So is this some kind of bug in HTTP Node? Sorry for my ignorance.

Is this aknowledged or am i doing something wrong?

I believe it’s something with n8n HTTP node. I tried with Insomnia Client (Postman alternative) and it works fine.

n8n workflow:

Insomnia POST request:

curl --request POST \
  --url https://www.mywebsite.com/wp-json/wp/v2/media \
  --header 'Authorization: Basic MyCredsBase64Encoded==' \
  --header 'Content-Disposition: =attachment; filename=\"Δοκιμαστικό Κείμενο.csv\"' \
  --header 'Content-Type: text/csv' \
  --data dGVzdA==

Upload Result:
image

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