Sorry posted in VB.net not C# thanks for moving.
Yes, I was missing the await keyword. Just came back to update that and found the responses.
I'm not getting "Converting null literal or possible null value to non-nullable type." over this line,
Code:
playerList = JsonSerializer.Deserialize<List<Player>>(responseString);
And via try catch getting this when running the application
Code:
System.Text.Json.JsonException: The JSON value could not be converted to System.Collections.Generic.List`1[MyProgram.Classes.Player]. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at MyProgram.PlayerList.getPlayersAPI() in C:\Users\bevan\source\repos\MyProgram\MyProgram\Pages\PlayerList.xaml.cs:line 55
My Player object is very simple
Code:
public class Player
{
public int Id { get; set; }
public required string fullName { get; set; }
}
JSON is like this
HTML Code:
{"Players": [{"Id":5,"FullName":"Thomas Smith"},{"Id":74,"FullName":"John Anderson"}]}