调用WebAPI保存单据报错!给定关键字不在字典中
金蝶云社区-究极鹏鹏
究极鹏鹏
0人赞赏了该文章 2,081次浏览 未经作者许可,禁止转载编辑于2018年03月08日 17:53:58

{"Result":{"ResponseStatus":{"ErrorCode":500,"IsSuccess":false,"Errors":[{"FieldName":"给定关键字不在字典中。","Message":" 在 System.ThrowHelper.ThrowKeyNotFoundException()\r\n 在 System.Collections.Generic.Dictionary`2.get_Item(TKey key)\r\n 在 Kingdee.BOS.WebApi.FormService.Save.Revole()\r\n 在 Kingdee.BOS.WebApi.FormService.Save.Execute()\r\n 在 Kingdee.BOS.WebApi.FormService.BillOperationService.ExecuteOperation(FormOperation op, String data)","DIndex":0}],"SuccessEntitys":[],"SuccessMessages":[]}}}
单据是继承的基对象模板里不带分录的业务单据,然后自己添加了{\"FLY\":\"xxxxxx\",\"FCDkey\":\"9826GB3615\",\"FDatetime\":\"" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\",\"FEntity\":{}},就这三个字段

public string SaveZxBill()
{
string msg = "";
try
{


ApiClient client = new ApiClient("http://127.0.0.1/K3Cloud/");
object[] loginInfo = new object[] {
//"572048e678d358",//售后演示帐套Id
//"kingdee",//用户名
//"jd1234",//密码
"5a9cb65e7c9030",//正式帐套Id
"test",//用户名
"123456",//密码
2052};//语言id
var ret = client.Execute("Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser", loginInfo);
var result = JObject.Parse(ret)["LoginResultType"].Value();

// 登陆成功
if (result == 1)//(FID,FBILLNO,FDOCUMENTSTATUS,FLY,FCDKEY,F_PAEZ_DATETIME)
{
string json = "";
string sFormId = "PAEZ_LYB";
//保存数据
json = "{\"FLY\":\"xxxxxx\",\"FCDkey\":\"9826GB3615\",\"FDatetime\":\"" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\",\"FEntity\":{}}";
//走到这儿就返回msg上面的错误信息
msg = client.Execute(@"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save", new object[] { sFormId, json.ToString() });
}
else
{
msg = "登陆失败:" + ret;
}


}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}