Why is my HTTP Request node returning HTML instead of JSON?

Why is my HTTP Request node returning HTML instead of JSON?
I’m calling an API using the HTTP Request node.Normally,The endpoint should return JSON, but n8n keeps showing HTML containing a login page.
The same URL works in my browser.

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @ayorinde_obele, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@barn4k, @Wouter_Nigrini, @jabbson - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @ayorinde_obele

receiving HTML instead of JSON usually means the request isn’t actually reaching the API endpoint successfully

Common causes include:

Missing Authorization header or API key or an expired access token.

  • Following a redirect to a login page.
  • Calling the wrong endpoint.

Open the execution and inspect the status code, Response headers, final request URL

If the response starts with:

HTML

you’re almost certainly receiving a webpage instead of the API response

Compare the request headers against the API documentation and verify authentication is being sent correctly

Hi @ayorinde_obele Welcome!
Reproduce the browser’s exact request instead of rebuilding it by hand. In Chrome or Firefox devtools open the Network tab, load the endpoint, right click the request and choose Copy as cURL. In the HTTP Request node select Import cURL and paste it, and everything the browser was sending, session cookie included, carries across as it was sent. If that returns JSON, the missing piece is in what you just pasted.
Once you know which part matters, move it into a credential rather than leaving it in the node, a Header Auth credential holding the API token, since a copied session cookie expires.

Building on the earlier suggestions — the fastest way to see WHY you’re getting HTML is to make the node show you the full exchange:

  1. In the HTTP Request node, open Settings and enable “Include Response Headers and Status” (older versions: Options > Response > Full Response). Also set On Error to “Continue” temporarily so non-2xx responses don’t hide the body.
  2. Add Options > Redirects and turn Follow Redirects OFF for one run. If the status is 301/302, the location header tells you exactly where you were being sent — if it’s a /login or /signin path, it’s an auth problem; if it’s the same URL with a trailing slash or https, it’s a URL problem.
  3. Add a header Accept: application/json. Some frameworks content-negotiate and serve HTML to anything that looks like a browser-less client without that header.

Two gotchas that match “works in browser, HTML in n8n”:

  • If the API redirects to a different host (e.g. api.example.comauth.example.com), the Authorization header is dropped on the redirect for security, and you land on a login page. Fix: call the final URL directly.
  • If the HTML contains “Just a moment” or the response has a cf-ray header, it’s Cloudflare bot protection, not your config — you’ll need an official API endpoint or key instead of the browser URL.

Post the status code plus response headers from step 1 (redact cookies) and it’ll be obvious which case this is.