I am facing problem while passing object value to Web API. I am passing value using Anuglar5
{
"Company_User_Process_ID": 68,
"BankName": "1860 UBL , ABBOTTABAD",
"ChallanNo": "",
"AccountTitle": "",
"AccountNo": "",
"CompanyName": "sdasd",
"RegistrationNo": "",
"ProcessId": 1,
"PaymentType": false,
"Document_Pid": "",
"HeadsOfAccount": []
}
But I am getting Null
. I got some help from This Answer. But I observed that the object that I am passing is not same as I am getting in Web API with extra {}
{
{
"Company_User_Process_ID": 68,
"BankName": "1860 UBL , ABBOTTABAD",
"ChallanNo": "",
"AccountTitle": "",
"AccountNo": "",
"CompanyName": "sdasd",
"RegistrationNo": "",
"ProcessId": 1,
"PaymentType": false,
"Document_Pid": "",
"HeadsOfAccount": []
}
}
Here is the Code of Web API
public async Task<ResponseObject<ChallanDetailViewModel>> CreateChallanDetail(ChallanDetailViewModel model)
{
...... My code here
}
Here is the Model Class
public class ChallanDetailViewModel
{
public long Company_User_Process_ID { get; set; }
public string BankName { get; set; }
public string ChallanNo { get; set; }
public string AccountTitle { get; set; }
public string AccountNo { get; set; }
public string CompanyName { get; set; }
public string RegistrationNo { get; set; }
public int ProcessId { get; set; }
public int PaymentType { get; set; }
public string Document_Pid { get; set; }
public List<String> HeadsOfAccount { get; set; }
}
Client Side code that is passing object
this.http.post(url, model).map((response: any) => { return
response.json() }).toPromise();