我正在开发一个应用程序,我应该在其中获得包含以下属性的 formData 响应。问题是我无法获取属性,并且 JSON 属性对我不起作用。
[AllowAnonymous]
[HttpPost("postResponse")]
public async Task<IActionResult> ValidatePaymentAsync([FromForm] PaymentResponseDto response)
{
_logger.LogInformation ($"API Callback is working --- Response :{JsonConvert.SerializeObject(response)}");
return Ok(await _resourceService.ValidatePaymentAsync(response));
}
public class PaymentResponseDto
{
public string idSession { get; set; }
public string statusPBX { get; set; }
[JsonProperty("3DENROLLED")]
public string _3DENROLLED { get; set; }
public string id3D { get; set; }
public string check { get; set; }
}
问题伴随着
3DENROLLED
。响应包含该值,但我没有得到它。数据成员也不适合我。
您可以尝试将以下代码添加到program.cs:
builder.Services.AddControllers().AddNewtonsoftJson().ConfigureApiBehaviorOptions(o => {
o.SuppressInferBindingSourcesForParameters = true;
});