Python做Web API对接---分配原创
13人赞赏了该文章
1,740次浏览
编辑于2021年06月15日 17:10:50
# 分配数据
import json, requests
login_url = "http://ip/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc"
audit_url = "http://ip/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Allocate.common.kdsvc"
login_data = {"acctid": "", "username": "", "password": "", "lcid": 2052}
def login(): # 定义登录函数
login_response = requests.post(url=login_url, data=login_data)
return login_response.cookies
# 返回cookies,方便下次访问时携带
# 获取表名和数据,写入erp
# PkIds是物料内码,TOrgIds是目标组织内码,可通过查询接口获取
def allocateToErp(formId, data):
datas = {"PkIds": data, "TOrgIds": "100008,399867,448131,448132,448133,448134,448135,192901,1382935"}
data = {"FormId": formId, "Data": json.dumps(datas)}
response = requests.post(url=audit_url, data=data, cookies=login())
print(response.text)
推荐阅读