简体   繁体   中英

Web Api Rest returns a Json with data but in Postman don't

I'm creating a WebApi .net 4.6 in the debug mode shows me there are data:

调试模式 Update There's something wrong if the field "ClaseTipoDia" is null? When I see the result in postman returns and empty json

在此处输入图像描述

this is my object class...

     public class CurvaTipicaTO
{

    public string FrtID { get; set; }

    public DateTime Periodo { get; set; }

    public string Tipo { get; set; }

    public string TipoDia { get; set; }

    public double Periodo01 { get; set; }

    public double Periodo02 { get; set; }

    public double Periodo03 { get; set; }

    public double Periodo04 { get; set; }

    public double Periodo05 { get; set; }

    public double Periodo06 { get; set; }

    public double Periodo07 { get; set; }

    public double Periodo08 { get; set; }

    public double Periodo09 { get; set; }

    public double Periodo10 { get; set; }

    public double Periodo11 { get; set; }

    public double Periodo12 { get; set; }

    public double Periodo13 { get; set; }

    public double Periodo14 { get; set; }

    public double Periodo15 { get; set; }

    public double Periodo16 { get; set; }

    public double Periodo17 { get; set; }

    public double Periodo18 { get; set; }

    public double Periodo19 { get; set; }

    public double Periodo20 { get; set; }

    public double Periodo21 { get; set; }

    public double Periodo22 { get; set; }

    public double Periodo23 { get; set; }

    public double Periodo24 { get; set; }

    public string ClaseTipoDia { get; set; }

}

Do I need to convert my list to array or something else? this is my controller logic the specific method

 [HttpGet]
        public IHttpActionResult ConsultaTipicaPorTipoDia([FromBody] List<FiltroFronteraTO> lstFiltroFrontera, [FromUri] DateTime fecha)
        {
            XMlog.Info("Ingreso metodo Consulta Curva Tipica");
            try
            {

                if ((lstFiltroFrontera != null) && (lstFiltroFrontera.Count> 0))
                {
                    DGPRepository dGPRepository = new DGPRepository();
                    var result =   dGPRepository.ConsultaCurvaTipicaPorTipoDia(lstFiltroFrontera, fecha);

                    return Ok(result); 

                }
                else
                {
                    throw new System.ArgumentNullException("lstFronteras es Null");
                }

            }
            catch (Exception ex)
            {
                XMlog.Error("Error Producido al ListarCurvaTipica por Tipo de Dia  ==> ", ex);
                return BadRequest();
            }
        }

It was Simple the solution

add

using Newtonsoft.Json; to the class ** CurveTipicaTO ** that I need to have serialized

and decorate every atribute with:

[JsonProperty("Field namexxxx")]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM