How can I use `curl` to diagnose a "SyntaxError: Unexpected token '<'" JSON parsing error?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can I use `curl` to diagnose a "SyntaxError: Unexpected token '<'" JSON parsing error?
Asked by:
90 Viewed 90 Answers

Answer (90)

Best Answer
(398)
Use `curl -v ` to see the full request and response headers, including the HTTP status code. The `-v` flag provides verbose output. Check the response body. If it starts with `` or any other HTML tags, you'll know you're receiving HTML instead of JSON. Also check the `Content-Type` header; it should be `application/json` if the server is sending JSON correctly.