我是 Web api 和 json 的新手。我不知道调用 WebApi 中的方法。以下方法在 Webapi 中:
[HttpGet]
public bool AddAccount([FromRoute]string accountname)
{
try
{
BizFramework.Web.Model.Account data = new BizFramework.Web.Model.Account();
data.AccountGuid = Guid.NewGuid();
data.AccountName = accountname;
data.ParentAccountID = 0;
data.AccountTypeID = 13;
data.AccountNo = "8060";
data.Active = true;
data.HierarchyLevel = 1;
data.CashFlowID = 3;
data.OpeningBalanceDate = DateTime.Now;
data.IscashBasis = true;
data.Createdby = "BAOwner";
data.CreatedDatetime = DateTime.Now;
data.Modifiedby = "BAOwner";
data.ModifiedDatetime = DateTime.Now;
BA.AddToAccounts(data);
BA.SaveChanges();
return true;
}
catch (Exception ex)
{
File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", ex.ToString());
return false;
}
}
使用此链接:
http://example.com/CustomerPortalService12/AddAccount/AccountsReceivable
我可以补充。但是通过编码我该如何添加?