K3Cloud 采购员 采用Web API 写入
金蝶云社区-MyCloud_1
MyCloud_1
0人赞赏了该文章 753次浏览 未经作者许可,禁止转载编辑于2016年08月19日 14:08:31

请问大家,你们K3Cloud中的采购员有新增、保存、列表按钮吗?我的平台见下图:

我在新增采购员时用的以下代码
public void Submit(string sFormId, SaveModel saveModel)
{
try
{
//管理中心站点
ApiClient client = new ApiClient(WebAPIConfig.CloudUrl);
//调用登录接口,参数,数据中心ID,用户名,密码,语言id
bool ret = client.Login(WebAPIConfig.DbId, WebAPIConfig.UserName, WebAPIConfig.PassWord, WebAPIConfig.Lcid);

//登录成功
if (!ret)
{
throw new Exception("WebAPI登录失败,可能是配置错误或者网络问题!");
}

string strJson = JsonConvert.SerializeObject(saveModel);
object[] subInfo = new object[]
{
sFormId,
strJson
};
var strRet = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save", subInfo);
WriteLog.WriteLogAndTime("WebAPI Msg" + strRet);

RetObject retObject = JsonConvert.DeserializeObject(strRet);
if (!retObject.Result.ResponseStatus.IsSuccess)
{
throw new Exception("接口错误!");
}
}
catch (Exception ex)
{
WriteLog.WriteLogAndTime("WebAPI接口错误" + ex.Message);
throw new Exception("接口错误" + ex.Message);
}
}

private void WebAPITest()
{
SaveModel saveModel = null;

try
{
//下面是测试代码
JObject model = new JObject();
JObject entity = null;

//添加编码
model.Add("FNUMBER", 0);
model.Add("FNAME", "张三");

saveModel = new SaveModel()
{
Creator = "Demo",
NeedUpDateFields = new JArray(""),
Model = model
};
string sFormId = "BD_BUYER";
WebAPIUtil util = new WebAPIUtil();
util.Submit(sFormId, saveModel);
}

提示如下错误:

请问是哪里出了问题,谢谢!