I am working a asp.net core 6.0 project.
when sending an API, The response of API has all fields until controller's last line. But in postman some Fields are missing
Example :
Here ticketed
is missing in postman response. But it is in controller.
I attached the images below.
Note :
I added NewtonsoftJson nuget package
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" />
in Program.cs
builder.Services.AddControllers(options =>
options.Filters.Add<ApiExceptionFilterAttribute>())
.AddFluentValidation()
.AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
Edit:
AirPriceVM.cs
public class AirPriceVM
{
public string TraceId { get; set; }
public Data Data { get; set; }
}
public class Data
{
public IEnumerable<AirPricePricingSolutionVm> AirPricingSolution { get; set; }
}
public class AirPricePricingSolutionVm
{
public string Key { get; set; }
public IEnumerable<AirPricePricingInfoVm> AirPricingInfo { get; set; }
}
public class AirPricePricingInfoVm
{
public bool Ticketed { get; set; }
public bool TicketedSpecified { get; set; }
}
// I removed some properties
in Controller
[HttpPost]
[Route("price")]
public async Task<ActionResult<AirPriceVM>> AirPrice([FromQuery] string siteCode, [FromQuery] string marketingMedium, [FromBody] GetAirPriceQuery dto)
{
dto.SiteCode = siteCode;
dto.MarketingMedium = marketingMedium;
var result = await Mediator.Send(dto);
return Ok(result); // until this line API response has "ticketed" . but in postman "ticketed" is missing
}
What did I miss here? Please anyone help me to find the mistake.
Thank you