Learn Build Community Opportunities Hosted n8n Blog About Careers Contact Log in

Home / Blog / Fix

Fix

Fix n8n http request node returns 401 when uploading to Telegram

A concise troubleshooting playbook to fix n8n HTTP uploads to Telegram that return 401 Unauthorized, with exact node settings and header checks you can apply now.

If your n8n http request node returns 401 when uploading animations, documents or videos to the Telegram Bot API, the fix is one of four causes: wrong token or Authorization header, using the download endpoint instead of the upload endpoint, incorrect binary handling in n8n, or manually overriding Content-Type and other headers. Fix those four and uploads will work.

Why n8n http request node returns 401

A 401 Unauthorized from Telegram usually means Telegram does not accept the credentials or the request shape. For uploads the common culprits are: you put the bot token in an Authorization header instead of in the URL, you are hitting the wrong hostname, n8n is not attaching a valid binary file, or you overrode multipart headers so Telegram cannot read the file. All produce a 401 rather than a 400 in many cases.

Step-by-step fix you can reproduce now

  1. Verify the token by calling a simple API method with curl or an n8n HTTP Request node:
    curl -s -X POST "https://api.telegram.org/bot/getMe"
    If this returns user info, the token is correct. If it returns 401, re-copy the token, watch for leading or trailing spaces, and confirm the bot token from BotFather.
  2. Check you are using the upload endpoint. For sending files you must call methods like /bot<TOKEN>/sendDocument, /bot<TOKEN>/sendAnimation or /bot<TOKEN>/sendVideo. Do not use the https://api.telegram.org/file/bot<TOKEN>/... path, because that path is for file downloads and will not accept uploads.
  3. Open the n8n node named HTTP Request and set these fields exactly:
    • Method: POST
    • URL: https://api.telegram.org/bot<TOKEN>/sendDocument (replace method name as needed)
    • Response Format: JSON
    • Body Content Type or equivalent: Form-Data (multipart)
    • Enable Send Binary Data and set Binary Property to the binary key from the previous node, for example data or file
    • Add a form-data field with the exact field name Telegram expects, for example document for sendDocument, animation for sendAnimation
  4. Do not set or override the Content-Type header manually. If you added a custom Authorization header, remove it. Telegram expects the token only in the URL path, not in a Bearer header, unless you intentionally configured header auth. In n8n, set Authentication to None unless using a specific header scheme.
  5. Test with a minimal known-good file. Use a small PDF, PNG or MP4 under a few MB to rule out large file or streaming issues. If you still get 401, enable node execution logging and inspect the request headers and form boundary that n8n created.
  6. If you use external binary storage (S3 or similar), confirm the binary property exists on the item and n8n actually attached the binary. An empty or missing binary property will produce malformed multipart data or no file part, which Telegram can respond to with 401 in some cases.

n8n specific node settings and header overrides

Here are the exact n8n controls to check. Open the HTTP Request node and verify the following UI fields:

  • URL: https://api.telegram.org/bot<TOKEN>/sendDocument or the method you need.
  • Method: POST.
  • Body Content Type: select Form-Data or the option that supports multipart.
  • Send Binary Data: checked.
  • Binary Property: the name of the binary key from the previous node, for example file or data.
  • Form-Data Parameter: add a row where Name is document or animation, and leave the value mechanism to n8n so it attaches the binary property.
  • Headers: remove any custom Authorization or Content-Type entries. Let n8n set the multipart boundary header automatically.

If you must add headers, only add non-content headers such as Accept: application/json. Never add Content-Type: multipart/form-data manually because you will miss the required boundary parameter.

Quick curl test to confirm the token, outside n8n

curl -F "document=@/path/to/file.pdf" "https://api.telegram.org/bot<TOKEN>/sendDocument"

If curl works and n8n fails, the problem is how n8n is attaching binary data or headers. Re-check the Binary Property setting and the item passed to the HTTP Request node.

Common error cases and exact fixes

  • Token vs header mismatch: If you used an Authorization: Bearer header or set Authentication in the node, remove it and use the token in the URL. Confirm no extra characters in the token string.
  • Wrong upload endpoint: Switch any /file/bot URLs to /bot<TOKEN>/sendX methods. Upload requests must go to the API method endpoints.
  • Binary handling: Ensure the input item actually contains binary data. Inspect the previous node output. If you used S3 external binary storage, make sure n8n has downloaded or attached the binary before the HTTP node.
  • File header mistakes: Remove manual Content-Type header. Let n8n create the multipart header with correct boundary.

How to stop this happening again

  • Keep a small test workflow that does a getMe call and a small sendDocument using a static test token for quick verification after changes.
  • Use named credentials in n8n if available, so you never paste tokens into ad hoc nodes and accidentally add headers.
  • Add an execution check step before uploads that verifies Boolean($binary) or that the binary property exists. Fail early with a clear error instead of sending a malformed request.
  • Document the rule in your team: token only in URL, no manual Content-Type, use Send Binary Data.

When to get help

If you confirmed the token and curl tests work but n8n still returns 401 after adjusting the above, capture the node request and response and share them with the n8n community. The n8n forum thread where users reported this exact symptom is useful for context: see the report about HTTP Request node returns 401 when sending animation or document/video. If binary storage is involved, check the related S3 binary storage thread for symptoms that look like missing binary payloads: S3 external binary storage issues.

If you prefer one-line triage, run curl to /getMe, then curl to a simple /sendDocument with a small file. If both succeed, the issue is n8n node configuration. If curl fails, the token or bot setup is the problem.

To learn more automations and stable patterns for API uploads, join Automate Naija training and workshops. You can also read our post on keeping n8n polling triggers reliable for other production protections: N8n polling trigger stops, heartbeat and watchdog fix.

Learn to build automations like this with Automate Naija.

Frequently asked questions

Why do I get 401 from Telegram but curl works locally?

If curl succeeds but n8n returns 401, the problem is how n8n builds the HTTP request. Check that you enabled Send Binary Data , set the correct Binary Property , used the method endpoint like /bot TOKEN /sendDocument , and removed any manual Content-Type or Authorization headers.

Can I put the token in an Authorization header instead of the URL?

Telegram expects the bot token in the URL path for the standard Bot API endpoints. If you place a Bearer or Authorization header, Telegram may not accept it and you can see a 401. Use https://API.telegram.org/bot TOKEN /METHOD or follow Telegram documentation for alternative auth.

What if my file is stored in S3 or external storage?

If binary is external, ensure n8n has resolved and attached the binary to the workflow item before the HTTP Request node. An empty or missing binary property creates malformed multipart data. Check the previous node output for a valid binary key and size.

I still see 401 after following this guide, what should I share when asking for help?

Share the curl output that works or fails, the n8n HTTP Request node screenshots of settings, the outgoing request headers and body summary from execution logs, and the exact response body and status text. That lets helpers check token placement, form-data, and headers quickly.


Build it with us. The community is free and the build track teaches this kind of automation week by week: see pricing or join the community.

Keep reading

A new fix lands here every morning, picked from what builders are stuck on right now.