ecology|泛微ecology9流程新建接口

最近发现泛微ecology9的接口文档,这篇文章我们简单测试下流程创建的场景。

参考文档

泛微接口文档
注:在这篇文档中介绍了不同接口的调用方式,基本都是POST方式,通过请求参数实现接口调用。其中测试发现在接口调用时还需要封装headers,需要在headers中传以下参数:token,appid,userid (参照《ecology|泛微ecology9获取token信息》)

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests
import base64
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5 as Cipher_pkcs1_v1_5

# RSA加密
def encode_RSA(secret):
public_key = '''-----BEGIN RSA PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAutgI110nsPC7PCq4wseLFd0XGmmaeJW+8qlJs+6YSbEQIDAQAB
-----END RSA PUBLIC KEY-----
'''
secret = secret.encode('utf-8')
rsakey = RSA.importKey(public_key)
cipher = Cipher_pkcs1_v1_5.new(rsakey)
cipher_text = base64.b64encode(cipher.encrypt(secret))
return cipher_text

# 获取token
def getToken(secret):
url = 'http://id:host/api/ec/dev/auth/applytoken'
headers = {'appid': 'test','secret':secret}
response = requests.post(url, headers=headers )
return response

# 创建流程
def createWorkflow(token,userid,param):
url = "http://ip:host/api/workflow/paService/doCreateRequest"
headers = {
'token': token,
'appid': 'test',
'userid': userid,
'Content-Type' : 'application/x-www-form-urlencoded; charset=utf-8'
}
response = requests.request("POST", url, headers=headers,data=param)
print(response.text)

if __name__ == '__main__':
secret = '81ab3d9a83d34ed5b33'
secretRSA = encode_RSA(secret)
userid = encode_RSA('683')
response = getToken(secretRSA)
param = {
"mainData" : '[ { "fieldName": "lxdlx", "fieldValue": "1" }, { "fieldName": "ngbm", "fieldValue": "111" },{ "fieldName": "ngsj", "fieldValue": "2023-08-29" }, { "fieldName": "ngr", "fieldValue": "683" }, { "fieldName": "cbbm", "fieldValue": "109" }, { "fieldName": "lxdnr", "fieldValue": "api/doCreateRequest测试联系单内容" },{ "fieldName": "lxdfj", "fieldValue": "58377" }, { "fieldName": "bz", "fieldValue": "接口推送流程测试0831" } ]' ,
"requestName" : "接口推送流程测试0831999",
"workflowId" : "105"
}
if response.status_code == 200 :
token = response.json()['token']
createWorkflow(token,userid,param)

商业转载请联系作者获得授权,非商业转载请注明出处。

支付宝打赏 微信打赏

如果文章对你有帮助,欢迎点击上方按钮打赏作者

ecology|泛微ecology9流程新建接口
http://hncd1024.github.io/2023/08/29/Ecology_apidoCreateRequest/
作者
CHEN DI
发布于
2023-08-29
许可协议