Skip to content

Handle ResponseContent is not JSON #164

@ptpaterson

Description

@ptpaterson

If a non 2XX error code is received, then resultRequest.ResponseContent is deserialized by Newtonsoft.Json.

var wrapper = JsonConvert.DeserializeObject<ErrorsWrapper>(resultRequest.ResponseContent);

However, the ResponseContent received is sometimes not JSON. One user received the following error; it's possible that the ResponseContent is html rather than a JSON string.

Error :Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

It may be helpful to handle this error more gracefully and provide the user with a better message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions