aPaas应用调用接口说明:
1、首先获取apaas应用列表。
2、根据应用列表返回的结果,找到要处理的应用。调用表单列表接口获取所有表单。
3、在表单列表中找到要处理的表单。调用表单详情接口获取表单设计。
4、根据表单设计,填充数据。
以下是nodejs代码示例
function logJSON(obj) {
console.log(JSON.stringify(obj))
}
const host = "https://根据文档获取对应的域名";
const userToken = "your token"
// 1、首先获取apaas应用列表。
async function get_custom_apps() {
return fetch(`${host}/apaas/api/v2/custom_apps?page=1&per_page=100`, {
"headers": {
"accept": "application/json;charset=utf-8",
"authorization": `Token token=${userToken}, device=pc`,
"content-type": "application/json;charset=utf-8",
"user-token": "ikcrm140fce32061e921687928a90fbb2fde6",
},
"method": "GET"
}).then(resp => resp.json());
}
//2、根据应用列表返回的结果,找到要处理的应用。调用表单列表接口获取所有表单。
async function get_custom_forms(custom_app_id) {
return fetch(`${host}/apaas/api/v2/custom_forms?custom_app_id=${custom_app_id}&page=1&per_page=1000`, {
"headers": {
"accept": "application/json;charset=utf-8",
"authorization": `Token token=${userToken}, device=pc`,
"content-type": "application/json;charset=utf-8",
},
"method": "GET"
}).then(resp => resp.json());
}
//3、在表单列表中找到要处理的表单。调用表单详情接口获取表单设计。
async function get_custom_form_detail(custom_form_id) {
return fetch(`${host}/apaas/api/v2/custom_forms/${custom_form_id}`, {
"headers": {
"accept": "application/json;charset=utf-8",
"authorization": `Token token=${userToken}, device=pc`,
"content-type": "application/json;charset=utf-8"
},
"method": "GET"
}).then(resp => resp.json());
}
// 4、根据表单设计,填充数据。
async function create_form_entities(custom_form_id, entity_data) {
return fetch(`${host}/apaas/api/v2/form_entities?custom_form_id=${custom_form_id}`, {
"headers": {
"accept": "application/json;charset=utf-8",
"authorization": `Token token=${userToken}, device=pc`,
"content-type": "application/json;charset=utf-8",
},
"body": JSON.stringify(entity_data),
"method": "POST"
}).then(resp => resp.json());
}
async function main() {
let custom_apps = await get_custom_apps();
logJSON(custom_apps);
let custom_forms = await get_custom_forms(65);
logJSON(custom_forms);
let custom_form_detail = await get_custom_form_detail(118)
logJSON(custom_form_detail)
let dumy_entity_data = {
"form_entity": {
"tex_17213533128b": `项目测试${new Date().toISOString()}`,
"user": {
"uid": 35903642,
"name": "姜河",
"third_userid": ""
},
"department": {
"did": 13388089,
"name": "演示平台(项目型)",
"third_dept_id": null
},
"cu_rela_17533284417a": {
"relation_source": {
"name": "contract",
"label": "合同",
"external_type": "crm"
},
"value": 2500580,
"label": "合同测试1",
"relation_data": {
"id": 2500580,
"primary_field_value": "合同测试1",
"title": "合同测试1",
"selected": false
},
"backfillData": true
},
"datet_17339076657c": "2025-07-07T16:00:00.000Z",
"floa_173390527845": "23",
"floa_173390528482": "23",
"cu_r_fo_17533408435b": {
"relation_record_maps": [
{
"_key": "j4dz9wsspui",
"id": null,
"tex_175334085153": "ret",
"floa_175334086714": "32.00",
"tex_are_17533408805b": "323fdsafds"
}
]
}
}
}
let entity = await create_form_entities(118, dumy_entity_data);
logJSON(entity)
}
main();
文档更新时间: 2025-07-24 15:14 作者:姜河