I have a web api end point with the declaration:
public async Task VisitorConnected(Guid? fingerprint, long property_id)
Sometimes I want to send null for the first parameter. I read on one of the threads to send it as "null" in a string quotation. However I'm getting:
System.IO.InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked.
---> System.FormatException: The JSON value is not in a supported Guid format.
at System.Text.Json.Utf8JsonReader.GetGuid()
at System.Text.Json.Serialization.Converters.JsonConverterGuid.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.JsonPropertyInfoNullable`2.OnRead(JsonTokenType tokenType, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.JsonPropertyInfo.Read(JsonTokenType tokenType, ReadStack& state, Utf8JsonReader& reader)
I tried to look it up in https://github.com/dotnet/corefx/blob/master/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.TryGet.cs#L940 but it appears that the Json Parser is not handling this null case. How can i achieve this, my second best option is to send an empty Guid 000-00000000-00-000... from the javascript client, and check in the web api controller, but feels like a hack.
fingerprintparameter? I mean, just don't send the parameter at all.nullfor yourfingerprintargument and handle the null check within your method.stringtype which is not nullable. So you want to type it as astring | null. Tldr, can you try sending from Postman?