!!!主要需要注意 serverUrl需要以/结尾!!!
需要注意引用Microsoft.Extensions.Configuration.Abstractions
1.
//serverUrl需要以“/”结尾
K3CloudApi client = new K3CloudApi("http://xxx.xxx.xxx.xxx/k3cloud/");
var ret = client.LoginByAppSecret("xx", "xx", "xx", "xx", 2052);
K3CloudApi client = new K3CloudApi(new ThirdPassPortInfo
{
ApiAppId = "xxx",
AppSec = "xxx",
CloudDbId = "x",xx
CloudUrl = "http://xxx.xxx.xxx.xxx/k3cloud/",
CloudUser = "xxx",
Language = "2052"
}, 1000);
- 也可以手动调用client.LoginByAppSecret
- 获取元数据
//读取配置,初始化SDK
K3CloudApi client = new K3CloudApi();
//用于记录结果
StringBuilder Info = new StringBuilder();
//请求参数,要求为json字符串PRD_PPBOM
string jsonData = "{\"FormId\":\"STK_InStock\"}";
//调用接口
string resultJson = client.QueryBusinessInfo(jsonData);
//对返回结果进行解析和校验,这里使用的是JsonPatch
JObject resultJObject = JObject.Parse(resultJson);
JToken queryNode = resultJObject.SelectToken("$..IsSuccess");
//判断并记录结果
if (queryNode == null)
{
Info.AppendLine("返回异常");
}
else
{
bool isSuccess = queryNode.Value<bool>();
Info.AppendLine(isSuccess ? "操作成功" : "操作失败");
if (isSuccess)
{
string originFile = "PoInBill";
FileInfo file = new FileInfo(@$"D:\work\code\MES1.5_API\MES.Common.DataAdapter\DataAdapter.Demo\Kingdee.CDP.WebApi.SDK.Test\元数据\{originFile}.txt");
File.WriteAllText(file.FullName, resultJObject.ToString());
}
}
- 子表id需要使用 Key_EntryPkFieldName 即从元数据中获取到的key和实体中主键字段名 例如: FInStockEntry_FEntryID
- 子表数据行号与子表id逻辑一致,使用key_SeqFieldKey拼接 即从元数据中获取到的key和实体中SeqFieldKey字段名 例如: FInStockEntry_FSEQ
[参考]
金蝶云php webapi,金蝶云星空(WebApi集成方式):免密码登录接口如何使用SDK?