However I try I get the following warning.
Severity Code Description Project File Line Suppression State Warning CS8600 Converting null literal or possible null value to non-nullable type.
The code is as follows.
HttpResponseMessage response = await _httpClient.PutAsync(url, requestContent);
string? userResponse = await response.Content.ReadAsStringAsync();
JsonSerializerOptions? options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
//if (userResponse.Length > 0)
//{
user = JsonSerializer.Deserialize<GetUserById>(userResponse, options);
//}
Looked at some posts like this and this, but could not figure out how to resolve.
Update.
I removed the if condition altogether, but still getting the warning.
Update 2
Added the null check as suggested. But still getting that warning.