Postman测试金蝶云星空Webapi【协同开发云】
环境说明
金蝶协同开发云环境
工作目录空间:D:\WorkSpace\开发商码
协同账套映射到本机的1200端口
//本机K3网址
http://localhost:1200/k3cloud
业务背景
基于金蝶云星空提供的接口测试,交付之前或者联调之前开发者先自测,即使纠错,提高效率。
大致流程
先请求登录接口,获得token后再请求标准webapi或者自定义接口,这样上下文才不会空。
具体操作
请求类型: POST
地址格式:http://localhost:1200/k3cloud/对应的方法拼接结构体
请求登录接口
请求地址
http://localhost:1200/Kingdee.bos.webapi.ServicesStub.authservice.validateuser.***mon.kdsvc
请求json:
{
"a***tid":"账套id",
"userName":"账号",
"password":"密码",
"lcid":2052
}
a***id:账套ID
userName:用户名
password:密码
lcid:语言【2052代表中文】
返回以上信息代表登录成功。
请求标准接口
查看
请求方式:POST
请求地址:
http://localhost:1200/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.***mon.kdsvc
请求体构建json:
{
"formid":"XXXX_AS_ProductLibrary",
"data":{
"CreateOrgId": 0,
"Number": "ZDY00000009HDC",
"IsSortBySeq": "false"
}
}
响应结果:
保存
请求方式:POST
请求地址:
http://localhost:1200/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.***mon.kdsvc
请求体构建json:
{
"formid":"XXXX_AS_ProductLibrary",
"data":{
"NeedUpDateFields": [],
"NeedReturnFields": [],
"IsDeleteEntry": "true",
"SubSystemId": "",
"IsVerifyBaseDataField": "false",
"IsEntryBatchFill": "true",
"ValidateFlag": "true",
"NumberSearch": "true",
"IsAutoAdjustField": "false",
"InterationFlags": "",
"IgnoreInterationFlag": "",
"IsControlPrecision": "false",
"ValidateRepeatJson": "false",
"Model": {
"FID": 0,
"FNumber": "XLH20231031001",
"FCreateOrgId": {
"FNumber": "10"
},
"FUseOrgId": {
"FNumber": "10"
},
"FName": "序列号001",
"FCustId": {
"FNUMBER": "CUST0001"
},
"FOrderNum": "SO2023001",
"FOrderInt": 2,
"FMaterialId": {
"FNUMBER": "010101076"
},
"FQty": 1,
"FProductionDate": "2023-10-17 00:00:00",
"FExpirationDate": "2023-12-16 00:00:00",
"FOutStockDate": "2023-10-31 11:13:25",
"FOutStockrNum": "XSCK001",
"FRemark": "测试备注",
"FDefinerOute": "test",
"FDeliveryNoticeNo": "D20231031001"
}
}
}
响应结果:
{
"Result": {
"ResponseStatus": {
"IsSu***ess": true,
"Errors": [],
"Su***essEntitys": [
{
"Id": 106428,
"Number": "XLH20231031001",
"DIndex": 0
}
],
"Su***essMessages": [],
"MsgCode": 0
},
"Id": 106428,
"Number": "XLH20231031001",
"NeedReturnData": [
{}
]
}
}
提交
请求方式:POST
请求地址:
http://localhost:1200/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.***mon.kdsvc
请求体:
{
"formid":"XXXX_AS_ProductLibrary",
"data":{
"CreateOrgId": 0,
"Numbers": ["XLH20231031001","XLH20231031002"],
"Ids": "",
"SelectedPostId": 0,
"***workCtrl": "",
"IgnoreInterationFlag": ""
}
}
响应结果
{
"Result": {
"ResponseStatus": {
"IsSu***ess": true,
"Errors": [],
"Su***essEntitys": [
{
"Id": 106427,
"Number": "XLH20231031001",
"DIndex": 0
},
{
"Id": 106428,
"Number": "XLH20231031002",
"DIndex": 1
}
],
"Su***essMessages": [],
"MsgCode": 0
}
}
}
审核
请求方式:POST
请求地址:
http://localhost:1200/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.***mon.kdsvc
请求体:
{
"formid":"XXXX_AS_ProductLibrary",
"data":{
"CreateOrgId": 0,
"Numbers": ["XLH20231031001","XLH20231031002"],
"Ids": "",
"SelectedPostId": 0,
"***workCtrl": "",
"IgnoreInterationFlag": ""
}
}
响应结果
{
"Result": {
"ResponseStatus": {
"IsSu***ess": true,
"Errors": [],
"Su***essEntitys": [
{
"Id": 106427,
"Number": "XLH20231031001",
"DIndex": 0
},
{
"Id": 106428,
"Number": "XLH20231031002",
"DIndex": 1
}
],
"Su***essMessages": [],
"MsgCode": 0
}
}
}
反审核
请求方式:POST
请求地址:
http://localhost:1200/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.***mon.kdsvc
请求体:
{
"formid":"XXXX_AS_ProductLibrary",
"data":{
"CreateOrgId": 0,
"Numbers": ["XLH20231031001","XLH20231031002"],
"Ids": "",
"SelectedPostId": 0,
"***workCtrl": "",
"IgnoreInterationFlag": ""
}
}
响应结果
{
"Result": {
"ResponseStatus": {
"IsSu***ess": true,
"Errors": [],
"Su***essEntitys": [
{
"Id": 106427,
"Number": "XLH20231031001",
"DIndex": 0
},
{
"Id": 106428,
"Number": "XLH20231031002",
"DIndex": 1
}
],
"Su***essMessages": [],
"MsgCode": 0
}
}
}
撤销
请求方式:POST
请求地址:
http://localhost:1200/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.CancelAssign.***mon.kdsvc
请求体和响应体都和提交、审核、反审核一致。
请求自定义接口
参数是字符串
请求方式:POST
请求地址:
http://localhost:1200/XXXX.K3.SCM.WebApi.ServicesStub.AfterOrder.GetAfterOrder.***mon.kdsvc
请求体构建json:
{
"customer":"XXXX电气有限公司"
}
响应结果
参数是实体类
单个实体类
请求方式:POST
请求地址:
http://localhost:1200/XXXX.K3.SCM.WebApi.ServicesStub.AfterOrder.GetAfterOrders.***mon.kdsvc
请求体构建json:
{
"ai":
{
"Cust":"ZZZZ电气有限公司",
"Number":"",
"Name":"蝴蝶床"
}
}
响应结果:
实体类是集合
请求方式:POST
请求地址:
http://localhost:1200/XXXX.K3.SCM.WebApi.ServicesStub.AfterOrder.GetAfterOrderList.***mon.kdsvc
请求体构建json:
{
"aiList":
[{
"Cust":"XXXX电气有限公司",
"Number":"",
"Name":"蝴蝶床"
},{
"Cust":"ZZZZ电气有限公司",
"Number":"",
"Name":"床"
}]
}
响应结果
其他
请求类型是POST如果改成GET请求,会报错
报错截图
响应结果:
{
"actionname": "ShowErrMsg",
"params": [
{
"errorTitle": "金蝶温馨提示: 应用服务器发生错误,请联系系统管理员检修!",
"errorInfo": "发生时间:\t2023-10-31 09:54:53\r\n错误编号:\t500\r\n错误信息:\t索引超出范围。必须为非负值并小于集合大小。\r\n参数名: index\r\n===================================================\r\n调用堆栈:\r\n 在 System.Collections.ArrayList.get_Item(Int32 index)\r\n 在 System.Collections.Specialized.NameValueCollection.GetKey(Int32 index)\r\n 在 System.Web.HttpValueCollection.Get(Int32 index)\r\n 在 Kingdee.BOS.ServiceFacade.KDServiceFx.JQueryRequestExtractor.GetByGet(HttpRequest request) 位置 d:\\k3cloudbuild\\BOS_V7_PT\\BOS\\ServiceFacade\\Src\\Kingdee.BOS.ServiceFacade.KDServiceFx\\Pipeline\\JQueryRequestExtractor.cs:行号 35\r\n 在 Kingdee.BOS.ServiceFacade.KDServiceFx.RequestExtractor.Create(HttpRequest request) 位置 d:\\k3cloudbuild\\BOS_V7_PT\\BOS\\ServiceFacade\\Src\\Kingdee.BOS.ServiceFacade.KDServiceFx\\Pipeline\\RequestExtractor.cs:行号 50\r\n 在 Kingdee.BOS.ServiceFacade.KDServiceFx.KDSVCHandler.ProcessRequest(HttpContext context) 位置 d:\\k3cloudbuild\\BOS_V7_PT\\BOS\\ServiceFacade\\Src\\Kingdee.BOS.ServiceFacade.KDServiceFx\\HttpHandlers\\KDSVCHandler.cs:行号 20\r\n 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n 在 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)\r\n 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& ***pletedSynchronously)\r\n\r\n"
}
]
}
因此请求类型不可以混用,要对,基本就是POST请求。
POST请求和WebAPI之间的区别是:
-
POST请求是HTTP协议的一种请求方式,用于向服务器提交数据,通常用于表单提交数据;而WebAPI是一种服务,提供了一组RESTful接口,用于向服务器请求数据。
-
POST请求是一种客户端向服务器发送数据的方式,通常用于表单提交等场景;而WebAPI则是一种服务器端提供数据的方式,客户端可以通过接口从服务器获取数据。
-
POST请求需要指定请求的URL和提交的数据,服务器可以根据请求的URL来处理数据;而WebAPI则需要客户端通过URL和参数指定要请求的数据,服务器在接收到请求后返回所需的数据。
总之,POST请求和WebAPI服务是两种不同的概念,POST请求用于提交数据,而WebAPI用于提供数据服务。