Skip to content

Error when Content-Type is text/plain; tool attempts to parse as JSON #676

@LinuxSuRen

Description

@LinuxSuRen

When sending a request with Content-Type text/plain;charset=UTF-8, the tool incorrectly attempts to parse the response as JSON and throws an error: "Unexpected token '测', '测试' is not valid JSON".

Steps to Reproduce

  1. Create a GET request with:

    • URL: http://localhost:8080/api/hello/message?key=testMessage
    • Header: Content-Type: text/plain;charset=UTF-8
  2. Send the request containing plain text content ("测试") in the body.

Expected Behavior

The tool should:

  1. Recognize the Content-Type header
  2. Display the plain text response without attempting JSON parsing
  3. Show the response text ("测试") in the output panel

Actual Behavior

  • Error message appears: "Unexpected token '测', '测试' is not valid JSON"
  • The response body is not properly displayed as plain text

Additional Context

  • Version: [Insert tool/version number here]
  • Environment: [Browser/OS if applicable]
  • API Endpoint: Shows "status code: 200" but fails to render content

Image

Proposed Fix

Modify the response handling to:

  1. Check the Content-Type header before processing
  2. Use appropriate renderer based on Content-Type
  3. Fallback to plain text display if content isn't parseable as JSON

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions