Once again facing another MVC issue. Someday, I'll look back at my "MVC learning days" and smile.
So here's the problem - a constant 400 response. Despite reading numerous posts on SO, I just can't seem to get my logic working. Maybe if I show you the logic, someone could help me out.
Controller:
public JsonResult CreateExtendedProperty(ExtendedPropertyDefinitionViewModel extendedPropertyDefinitionViewModel)
{
//I started with JsonResult as ActionResult, but no luck yet.
var p = extendedPropertyDefinitionViewModel;
//Temp
//return Json(new { Success = false, ErrorMessage = "Error creating property" });
}
The Ajax/Javascript:
var extendedPropertyDefinition = JSON.stringify({
DefinitionId: '0',
Title: propertyInfo["Title"],
OrganisationId: '0',
Organisation: '',
TypeId: propertyInfo["TypeId"],
SortOrder: 0,
IsEnumerated: propertyInfo["IsEnumerated"],
AllowMultiSelect: propertyInfo["AllowMultiSelect"],
IsDate: propertyInfo["IsDate"],
LastUpdatedBy: "",
LastUpdatedDateTime: new Date().toISOString(),
CreatedBy: "",
CreatedByDateTime: new Date().toISOString(),
Options: {
OptionId: '0',
Option: '',
OptionValue: '',
SortOrder: 0,
LastUpdatedBy: '',
LastUpdatedDateTime: new Date().toISOString(),
CreatedBy: '',
CreatedByDateTime: new Date().toISOString(),
}
});
$.ajax({
url: "<%= Url.Action('CreateExtendedProperty', 'Organisation') %>",
contentType: "application/json; charset=utf-8",
dataType: "json",
//traditional: true,
type: 'POST',
data: extendedPropertyDefinition,
success: function(e) {
alert('success');
//Rebuild Grid?
},
error: function(e) {
alert('request failed (500)');
}
});
The payload: https://i.sstatic.net/1xkYU.png
Hoping someone can guide me in the right direction, any help would be greatly appreciated.
Regards,