Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

API Returns HTML Instead of JSON: Find the Layer Causing It

An “Unexpected token <” error often points to an HTML response, not a broken JSON parser. Use the URL, headers, redirects, and body to find which layer returned it.

If an API client reports Unexpected token '<', first check the response—not the parser. The body may be an HTML login page, frontend fallback, or server or proxy error instead of JSON. Record the status, final URL, Content-Type, and a short raw-body preview; together, those clues help identify which layer answered the request.

What the response can tell you

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

No single clue proves the cause in every stack. Compare the response status, redirect history and final URL, Content-Type, body signature, and the system responsible for the response: API handler, authentication layer, frontend router, or proxy. A body beginning with < is a useful warning that the response may be HTML, but inspect it rather than assuming the parser is at fault.

  • Login form or authentication message: check whether credentials are missing, invalid, or formatted incorrectly.
  • Frontend app shell: check the request URL and route. A wrong path or prefix can land on a website fallback rather than an API handler.
  • Server or proxy error text: investigate the component that generated the error and whether it returned the representation your client expects.

Microsoft’s ASP.NET Core documentation describes an API call expecting JSON receiving an unhandled-exception response with Content-Type: text/html. It also explains that an API can be configured to return JSON for errors, including missing endpoints. Microsoft’s API error-handling guidance is specific to ASP.NET Core; other frameworks have their own error-handling configuration.

As an Amazon Associate I earn from qualifying purchases.

Trace the response from request to body

  1. Verify the request target. Record the method, host, path, environment, and complete URL. Compare them with the API documentation, including any required base path or version prefix. Seeing /api/ in a URL does not prove the intended API handler received the request.
  2. Inspect status and headers. Check the HTTP status and Content-Type, then read a short preview of the raw body before attempting to parse it. The header is informative, not conclusive: confirm the representation in the body too.
  3. Check redirects and the final URL. A client may follow a redirect and show the destination page, obscuring the original response. Inspect redirect history and compare the final URL with the API route you intended to call.
  4. Verify authentication. Confirm that the credentials and authorization format match the service’s instructions. For example, Cloudinary’s Admin API documentation identifies missing credentials and incorrectly formatted credentials as causes of HTML responses; it specifically calls out incorrect Base64 encoding when manually constructing the Authorization header. This is a Cloudinary-specific example, not a universal diagnosis. Cloudinary Admin API documentation
  5. Check the proxy path. If the request passes through a proxy, inspect its routing and diagnostics. Postman recommends reviewing its Console for proxy-server debugging information. Postman proxy troubleshooting
  6. If you own the API, inspect its error paths. Make missing-route and exception responses conform to the API’s documented machine-readable contract. In ASP.NET Core, Microsoft documents configuring API errors to return JSON rather than HTML.
  7. Parse only the representation you expect. Check the response before decoding it as JSON. Avoid silently swallowing parse failures: that can hide both the HTML body and the upstream status that would help locate the problem.

Match the evidence to the likely source

Observation Likely area to investigate Next check
HTML login or authentication error Authentication layer Verify credentials and authorization-header format against the service documentation.
Website shell or unrelated page URL, route, or frontend fallback Compare the actual request path and final URL with the documented API route.
HTML exception response API error handler or server Inspect server logs and configure API errors to use the documented response format.
Proxy-branded error or unexpected routing Proxy or network path Review proxy diagnostics and request details, including Postman Console output when applicable.

These are diagnostic patterns, not guarantees. A status code or header alone does not identify the responsible layer; use the URL, redirects, headers, and body together.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the API’s error contract predictable

If you maintain the API, define machine-readable responses for expected failures as well as successful requests. Error handling should cover missing routes and unhandled exceptions, not just the endpoint’s normal return path. Microsoft’s ASP.NET Core guidance describes configuring a web API to return JSON for missing endpoints and unhandled exceptions. Ensure the client can distinguish an API error from a response generated by a frontend or intermediary.

#1 Best Overall
Treedix USB Cable Tester 2.4" Screen for eMarker PD3.0/3.1 Resistor
  • 【USB Cable Performance Testing】Test USB cable continuity, functionality (charging, data transfer, high-speed signal), and measure internal resistance for power efficiency. Verify ground wire connection to outer shell for cable integrity, safety, and shielding.
  • 【Type-C eMarker Chip Reading】Reads eMarker chip parameters in Type-C cables, providing detailed performance information (e.g., maximum current, voltage, data transfer rates) to help users fully understand cable capabilities and ensure safe, efficient device usage.
  • 【High-Definition Color Display】 The USB cable checker features a 2.4-inch high-definition color display. With the left white button, you can easily switch between function pages to view real-time detailed status of the cable, including internal resistance, power delivery efficiency, and cable quality. This helps you quickly identify inferior cables.
  • 【Wide Compatibility】The usb tester can accurately identify and verify USB cable versions, including USB 2.0 and USB 3.2. It integrates PD 3.0 and PD 3.1 protocol detection functions, enabling quick verification of whether the cable supports the latest PD 3.0/3.1 standards, ensuring the cable meets high-power charging and fast data transfer requirements.
  • 【Multiple Power Supply Options】The black button on the left can flexibly switch the power supply mode, and support the use of AAA battery or Type C 5V to stably supply power to the USB tester

On the client side, preserve enough information to diagnose a mismatch: status, response headers, final URL, and a safe preview of the body. Do not treat every non-JSON response as a JSON parsing problem; it may be evidence that a different layer handled the request.

Rank #4
AVHzY USB Power Meter USB 3.1 Tester Digital Multimeter Current Tester Voltage Detector Lua Interpreter Integrated DC 26V 6A PD 2.0/3.0 QC 2.0/3.0/4.0 pps Trigge
  • 0-26V 0-6A voltage & current measurement. 128*160 1.77’TFT. 4.5 digits reading for voltage and current. 0.1% maximum gain error for both voltage and current. Capacity/Energy accumulator. PD(with PPS), QC2.0, QC3.0, QC4.0, Huawei SCP, SSCP, FCP, Samsung AFC, VOOC, Super VOOC 65W trigger for charger testing.
  • Powerful PC software: Data logging up to 1000sps. Lua program downloader. VBUS ripple viewer(3.2Msps). PD listener for device diagnosis. Fast-charge trigger and external load module can also be accessed. All functionalities can be activated simultaneously for advanced test requirements.
  • Lua Programmable: Lua interpreter integrated, provided with various APIs, detailed documentations (Look up at point 1). Make access to almost all hardware with your own program. Scripts can be set to run on boot. Internal 12Mbytes memory can be used to store scripts, and can be used as output storage of scripts (Standard file operation supported).
Rank #3
diymore USB Tester USB Meter Tester Voltage Current Tester USB Battery Checker USB A Voltage Current Voltmeter Amp Volt Ammeter Detector USB Mobile Tester USB Cable Charger Detector LED Display
  • 【 USB Power Mete Voltage Current Tester】 The USB volt meter checker can detects Voltage,Current,of the USB.usb tester Perfect phone charger tester of charging speed and quality.voltage tester Measuring voltage: 3.0V-7.5V;measuring current: 0-2.5A.
  • 【 Electrical Tester Upgraded Color Display Screen 】 Battery capacity tester current number is displayed in red and the voltage number is displayed in blue, voltmeter tester large size letters which is clear and easy to read.
  • 【 Usb Tester Voltage Current Tester High Quality 】 USB cable tester usb amp read tester uses a new generation of power four semi double loop integral converter IC,usb a tester with a precision bandgap reference,range accuracy,high precision,wattage meter stable and reliable performance,strong anti~interference ability.
  • 【 Voltage Meter Tester Wide Range of Application 】 USB voltage meter USB voltage checker can measure USB powered or power consumption of the interface,mobile phone charger,disk and other products. Easily measure the operating current of the output voltage of the USB port and equipment.
  • 【 USB C Power Meter Small and Portable 】 Our Usb tester is smallsize and no power, just plug to detect USB charger output voltage and current.
Rank #2
Eversame 2 in 1 Type C USB Tester Color Screen LCD Digital Multimeter, USB C Voltage Current Voltmeter Amp Volt Ammeter Detector USB Cable Charger Indicator, DC3.6-30V/0-5.1A
  • UPGRADED MULTIFUNCTIONAL USB C POWER METER: Detects the charging status and process of your USB-enabled or type c-enabled devices. Supports QC3.0, QC2.0 and BC1.2. A Must Gadget checks the charging performance (charging speed and quality) of the output wall/car/solar panel chargers and USB charging cables. It can be also used to find the highest current of the Wireless Charger, and test capacity and electric energy of power bank
  • PROFESSIONAL SAFETY GUARD: Featured with over-voltage protection, over-current protection, under-voltage protection, low energy protection and alarm system. This upgraded USB Type C tester can detect safety and maximally protect the appliances from damaging. It will cut off output automatically and alarm by sound, while it will save data when power off suddenly
  • MULTIPLE COLOR SCREEN DISPLAY MODES: New upgraded version offers 8 LCD main color screen display interfaces, allowing switching the display interface by pressing the key. With the new interface settings, this instrument can monitor voltage, current, capacity, electric quantity, power, load impedance, D+/D- voltage and other data of USB
  • WIDE RANGE OF APPLICATION: Thanks to the PD protocol quick charging mode measurement technology, this new multimeter supports the updated iPhone X mobile phone. (Support iphone 8 / 8P / iPhone Xs quick charging, 29W power, 5V3A / 9V3A / 12V2.5A / 15V2A). It also can be applied to test other type C devices, Compatible With Galaxy S10/S9/Note 10 +, ChromeBookPixel, OnePlus and More
  • QUALITY COMMITMENT: We always believe in the stability and continuous improvement of product quality. Package includes 1 x USB Tester. (Note: If the USB tester does not show any parameters, please insert the small adapter sent with the package into the side hole of the USB tester to trigger the PD charging function)

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.