Код: Выделить всё
[HttpGet]
[Route("order/{orderId:long}")]
public async Task GetOrderAsync(int orderId)
{
try
{
return await ProcessRequestAsync(
requestParameter,
requestMethod,
response => Ok(response)
[b] мои выводы: < /strong> < /p>
Ответ не нулевой, он имеет правильные значения. /li>
Ответ имеет сложный объект. это. Я проверил работу метода OK Код: Выделить всё
Response
- Object1 (Which doesn't have any exception in properties)
- Object2 (Which doesn't have any exception in properties)
- Object3 (Which has exception in few properties)
- More explanation about Object3, when you expand it, it will have most properties as Decimal which are not initialized because I don't need them and they are null, due to which Ok is failing to render them as the output.
Код: Выделить всё
private static void ConfigureServices(IServiceCollection serviceCollection, IConfiguration config)
{
serviceCollection.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.IgnoreReadOnlyProperties = true;
options.JsonSerializerOptions.WriteIndented = true;
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
});
}
Всякий раз, когда я пытаюсь выполнить конечную точку, я получаю ответ ниже в своем чванстве: < /p>
Код: Выделить всё
{
"Message": "Nullable object must have a value."
}
< /code>
Also note that the properties in the response are coming from a nuget package therefore I can't use JsonIgnore on the property.Есть ли какой -нибудь способ помочь мне?
Подробнее здесь: https://stackoverflow.com/questions/793 ... e-endpoint
Мобильная версия