Reputation: 324
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": "[email protected]",
"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:
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.
Upvotes: 0
Views: 460
Reputation: 2516
0x0000007a
in Hex = 122
in Dec. Check your debugger settings. Debugger seems to be set to display integers in Hex.
Upvotes: 2