Skip to content

PUT with non-JSON body emits spurious error #66

@rriegs

Description

@rriegs

Issuing

$.ajax({
    type: 'PUT',
    url: '/data/abc',
    contentType: 'text/plain',
    data: 'some plain text'
})

results in

> #12 PUT /data/abc

JSON body could not be parsed: Invalid JSON

< #12 200 [+3ms]

If one instead uses data: '"quoted text"', the result is:

> #13 PUT /data/abc

"quoted text"

< #13 200 [+18ms]

and similarly for {"other": "valid JSON"} strings. Note this occurs even if setting contentType: 'text/plain', as shown. The error is purely cosmetic: other operation proceeds as normal. The behavior may have been introduced in #35 in response to #33.

I also note that GET requests print their response data if it is formatted as valid JSON, but otherwise print nothing without error, i.e. they must be checking whether the response is JSON-parsable before attempting to do so. (Actually, it looks like the real distinction is that non-JSON request payloads always cause the error, while response payloads check as appropriate.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions