FluentAssertions.Web icon indicating copy to clipboard operation
FluentAssertions.Web copied to clipboard

Deserialization when the response is an array, but the expected model is a single object

Open adrianiftode opened this issue 1 year ago • 0 comments

The expected model was a single object, and the response an array.

Expected response to have a content equivalent to a model of type "<>f__AnonymousType0`7[System.Int32,System.String,System.String,System.Int32,System.DateTime,System.Int32,System.Int32]", but the JSON representation could not be parsed, as the operation failed with the following message: "Exception while deserializing the model with SystemTextJsonSerializer: The JSON value could not be converted to <>f__AnonymousType0`7[System.Int32,System.String,System.String,System.Int32,System.DateTime,System.Int32,System.Int32]. Path: $ | LineNumber: 0 | BytePositionInLine: 1.". 

The HTTP response was:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 2025


***** Content is too large to display and only a part is printed. *****
[{"id":"03e9bf9d-5fec-4cdc-82a3-19c5fa1c847e","userName":"Utility",

adrianiftode avatar Sep 29 '22 21:09 adrianiftode