I have a problem in the http post method of angular, I have seen several tips but none works. Here is the code:
$scope.cadastrar = function () {
$http({
method: 'POST',
url: '/MinhaConta/Cliente/PostAnuncio',
data: $.param($scope.novo),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.success(function (data, status, headers, config) {
if (data.Status) {
$scope.hasMsg = true;
$scope.hasError = false;
$scope.hasSuccess = true;
$scope.infoMsg = data.Mensagem;
}
})
.error(function (data, status, headers, config) {
$scope.hasMsg = true;
$scope.hasSuccess = false;
$scope.hasError = true;
$scope.infoMsg = data.ErrorMessage;
});
};
I've placed the scope to display my object information as I'm inserting:
Iinsertedabreakpointtoseeiftheobjecthasvalue
Theresponsereturnsmeanerrorwhichisadefaultreturniftheobjectisnull.WouldanyoneknowtotellmewhatI'mdoingwrong?
{ "typeid": 0, "marcaid": 0, "model": 0, "versaoid": 0, "manufacturing": 0, "anomodelo": 0, "km": 0, "value": 0.0, "color": null, "fuel": null, "plate": null, "vscustom": null, "exchange": false }
public class NovoVeiculo
{
public int tipoid { get; set; }
public int marcaid { get; set; }
public int modeloid { get; set; }
public int versaoid { get; set; }
public short anofabricacao { get; set; }
public short anomodelo { get; set; }
public int km { get; set; }
public decimal valor { get; set; }
public string cor { get; set; }
public string combustivel { get; set; }
public string placa { get; set; }
public string vscustom { get; set; }
public bool troca { get; set; }
}
Thanks for the help right away.