0

I am implementing for the first time a POST in WebAPI from an Angular client that receives a JObject which I then deserialize to my objects of interest. But when I check the resulting object I see that all fields are appropriately filled except those meant to be integers.

This is part of my POST method

 // POST: api/PresupuestosApi
    [ResponseType(typeof(Presupuesto))]
    public async Task<IHttpActionResult> PostPresupuesto([FromBody]JObject presupuesto)
    {
        if (!ModelState.IsValid)
        {
            return BadRequest(ModelState);
        }
        try
        {
            Presupuesto p = presupuesto.ToObject<Presupuesto>();

My JSON looks like this:

{  
"sTitulo": "Agentasa",  
"cSolicitante": 
{
    "eRol": "SOLICITANTE",
    "sEmail": "bla@sdlfkjsf.com",
    "iTelefono": "122299935",
    "sNombre": "Clau",
    "sApellido": "Clau"  
},  
"cTrabajo": 
{
    "SNombreTrabajo": "Agenda"  

},  
"sMaterial": "sadsa",  
"sDimAbierto": "12x22",  
"sDimCerrado": "12x155",  
"sImpresion": "Una cara",  
"fGramaje": 12.5,  
"iCantidad": 122,  
 }

And my Presupuesto class is this:

public class Presupuesto
{
    private int iIdPresupuesto;
    private string sTitulo;
    private Solicitante cSolicitante;
    private Trabajo cTrabajo;
    private string sMaterial;
    private string sDimAbierto;
    private string sDimCerrado;
    private float fGramaje;
    private string sImpresion;
    private int iCantidad;
  }

So, when debugging I see this:

p object

I am lost as to why it is correctly parsing every other type but int. Any suggestions on this subject? I need to emphasize I have never worked with WebAPI before.

Kevin Kipp
  • 417
  • 6
  • 14
emmaielle
  • 314
  • 3
  • 12

1 Answers1

2

0x0000007a in Hex = 122 in Dec. Check your debugger settings. Debugger seems to be set to display integers in Hex.

Allen King
  • 2,372
  • 4
  • 34
  • 52